Skip to content

Commit

Permalink
Merge pull request #7 from nulib/fix-jwt-auth-flow
Browse files Browse the repository at this point in the history
If jwt is valid skip regular auth
  • Loading branch information
kdid authored Nov 18, 2024
2 parents 5a7abde + 91485e7 commit 443c2a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions iiif-server/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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",
Expand All @@ -115,7 +119,7 @@ async function viewerRequestIiif(request, { config }) {
}
}

const authed = await authorize(
const authed = jwtAuth || await authorize(
params,
referer,
cookie,
Expand Down
2 changes: 1 addition & 1 deletion iiif-server/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Resources:
Handler: index.handler
Architectures:
- x86_64
Timeout: 3
Timeout: 5
MemorySize: 128
AutoPublishAlias: "Latest"
AssumeRolePolicyDocument:
Expand Down

0 comments on commit 443c2a9

Please sign in to comment.