Skip to content

Commit 6e0cd60

Browse files
committed
fix: include user_id in JWT and validate user in passkey response
1 parent 54b47f1 commit 6e0cd60

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
455455
userVerification: this.options.passkeys?.settings.authenticatorSelection.userVerification || "required"
456456
},
457457
});
458-
const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge }, 'tempPasskeyChallenge', '10m');
458+
const value = this.adminforth.auth.issueJWT({ "challenge": options.challenge, "user_id": adminUser.pk }, 'tempPasskeyChallenge', '10m');
459459
this.adminforth.auth.setCustomCookie({response, payload: {name: "registerPasskeyTemporaryJWT", value: value, expiry: undefined, expirySeconds: 10 * 60, httpOnly: true}});
460460
return { ok: true, data: options };
461461
}
@@ -473,6 +473,9 @@ export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
473473
if (!decodedPasskeysCookies) {
474474
return { error: 'Invalid passkey token' };
475475
}
476+
if (decodedPasskeysCookies.user_id !== adminUser.pk) {
477+
return { error: 'Invalid user' };
478+
}
476479
const settingsOrigin = this.options.passkeys?.settings.expectedOrigin;
477480
const expectedOrigin = body.origin;
478481
const expectedChallenge = decodedPasskeysCookies.challenge;

0 commit comments

Comments
 (0)