From 91485e7cdff4217adbc2020e9c04b989b04c90d3 Mon Sep 17 00:00:00 2001 From: Karen Shaw Date: Wed, 13 Nov 2024 17:31:47 +0000 Subject: [PATCH] If jwt is valid skip regular auth --- iiif-server/src/index.js | 8 ++++++-- iiif-server/template.yaml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/iiif-server/src/index.js b/iiif-server/src/index.js index 1801beb..9190ef3 100644 --- a/iiif-server/src/index.js +++ b/iiif-server/src/index.js @@ -90,6 +90,7 @@ async function viewerRequestIiif(request, { config }) { const cookie = getEventHeader(request, "cookie"); const authSignature = getAuthSignature(request); + let jwtAuth = false; if (authSignature) { let jwtClaims; try { @@ -105,7 +106,10 @@ async function viewerRequestIiif(request, { config }) { const jwtResult = await validateJwtClaims(jwtClaims, params, config); - if (!jwtResult.valid) { + if (jwtResult.valid) { + console.log("JWT claims verified"); + jwtAuth = true; + } else { console.log(`Could not verify JWT claims: ${jwtResult.reason}`); return { status: "403", @@ -115,7 +119,7 @@ async function viewerRequestIiif(request, { config }) { } } - const authed = await authorize( + const authed = jwtAuth || await authorize( params, referer, cookie, diff --git a/iiif-server/template.yaml b/iiif-server/template.yaml index 17febb5..dacbcab 100644 --- a/iiif-server/template.yaml +++ b/iiif-server/template.yaml @@ -59,7 +59,7 @@ Resources: Handler: index.handler Architectures: - x86_64 - Timeout: 3 + Timeout: 5 MemorySize: 128 AutoPublishAlias: "Latest" AssumeRolePolicyDocument: