Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce client_id parameter to logout request #237

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions lib/src/core/authentication-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,7 @@ export class AuthenticationCore<T> {
);
}

const idToken = (await this._dataLayer.getSessionData(userID))?.id_token;

if (!idToken || idToken.trim().length === 0) {
throw new AsgardeoAuthException(
"JS-AUTH_CORE-GSOU-NF02",
"ID token not found.",
"No ID token could be found. Either the session information is lost or you have not signed in."
);
}

const callbackURL = configData?.signOutRedirectURL ?? configData?.signInRedirectURL;
const callbackURL: string = configData?.signOutRedirectURL ?? configData?.signInRedirectURL;

if (!callbackURL || callbackURL.trim().length === 0) {
throw new AsgardeoAuthException(
Expand All @@ -556,9 +546,24 @@ export class AuthenticationCore<T> {
);
}

const logoutCallback =
let parameter: string = `client_id=${ configData.clientID }`;

if (configData.sendIdTokenInLogoutRequest) {
const idToken: string = (await this._dataLayer.getSessionData(userID))?.id_token;

if (!idToken || idToken.trim().length === 0) {
throw new AsgardeoAuthException(
"JS-AUTH_CORE-GSOU-NF02",
"ID token not found.",
"No ID token could be found. Either the session information is lost or you have not signed in."
);
}
parameter = `id_token_hint=${ idToken }`;
}

const logoutCallback: string =
`${ logoutEndpoint }?` +
`id_token_hint=${ idToken }` +
parameter +
`&post_logout_redirect_uri=${ callbackURL }&state=` +
SIGN_OUT_SUCCESS_PARAM;

Expand Down
1 change: 1 addition & 0 deletions lib/src/models/client-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface DefaultAuthClientConfig {
*
*/
sendCookiesInRequests?: boolean;
sendIdTokenInLogoutRequest?: boolean;
}

export interface WellKnownAuthClientConfig extends DefaultAuthClientConfig {
Expand Down