Signed-off-by: jeffhuang <jeffwalt630@gmail.com> Signed-off-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -190,17 +190,16 @@ async function verifyOidcToken(token, env) {
|
||||
const header = decodeJwtPart(headerB64);
|
||||
const payload = decodeJwtPart(payloadB64);
|
||||
|
||||
if (!payload.exp || payload.exp < Date.now() / 1000) {
|
||||
return { valid: false, reason: "Token expired" };
|
||||
}
|
||||
if (env.MAX_TOKEN_AGE_SECONDS && payload.iat) {
|
||||
const age = Date.now() / 1000 - payload.iat;
|
||||
const age = Math.floor(Date.now() / 1000) - payload.iat;
|
||||
if (age > parseInt(env.MAX_TOKEN_AGE_SECONDS, 10)) {
|
||||
return { valid: false, reason: "Token too old" };
|
||||
}
|
||||
}
|
||||
|
||||
if (!payload.exp || payload.exp < Date.now() / 1000) {
|
||||
return { valid: false, reason: "Token expired" };
|
||||
}
|
||||
|
||||
const expectedIssuer = env.OIDC_ISSUER.replace(/\/$/, "");
|
||||
const actualIssuer = (payload.iss || "").replace(/\/$/, "");
|
||||
if (actualIssuer !== expectedIssuer) {
|
||||
|
||||
Reference in New Issue
Block a user