Skip to content

Commit

Permalink
Fix oidc flow
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Feb 9, 2024
1 parent a1848b0 commit 9afd31e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
7 changes: 3 additions & 4 deletions server/auth/types/openid/openid_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,12 @@ export class OpenIdAuthentication extends AuthenticationType {
cookie.authType !== this.type ||
!cookie.username ||
!cookie.expiryTime ||
(!cookie.credentials?.authHeaderValue && !this.getExtraAuthStorageValue(request, cookie)) ||
!cookie.credentials?.expires_at
(!cookie.credentials?.authHeaderValue && !this.getExtraAuthStorageValue(request, cookie))
) {
return false;
}

if (cookie.credentials?.expires_at > Date.now()) {
if (cookie.expiryTime > Date.now()) {
return true;
}

Expand All @@ -290,8 +289,8 @@ export class OpenIdAuthentication extends AuthenticationType {
cookie.credentials = {
authHeaderValueExtra: true,
refresh_token: refreshTokenResponse.refreshToken,
expires_at: getExpirationDate(refreshTokenResponse), // expiresIn is in second
};
cookie.expiryTime = getExpirationDate(refreshTokenResponse);

setExtraAuthStorage(
request,
Expand Down
3 changes: 1 addition & 2 deletions server/auth/types/openid/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,9 @@ export class OpenIdAuthRoutes {
username: user.username,
credentials: {
authHeaderValueExtra: true,
expires_at: getExpirationDate(tokenResponse),
},
authType: AuthType.OPEN_ID,
expiryTime: Date.now() + this.config.session.ttl,
expiryTime: getExpirationDate(tokenResponse),
};
if (this.config.openid?.refresh_tokens && tokenResponse.refreshToken) {
Object.assign(sessionStorage.credentials, {
Expand Down
1 change: 0 additions & 1 deletion server/auth/types/saml/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ export class SamlAuthRoutes {
if (tokenPayload.exp) {
expiryTime = parseInt(tokenPayload.exp, 10) * 1000;
}
console.log(expiryTime);

const cookie: SecuritySessionCookie = {
username: user.username,
Expand Down

0 comments on commit 9afd31e

Please sign in to comment.