Skip to content

Commit

Permalink
Merge pull request #237 from Yasasr1/v2.0.14-pre-release
Browse files Browse the repository at this point in the history
Introduce client_id parameter to logout request
  • Loading branch information
Yasasr1 authored Oct 3, 2023
2 parents dfbdc8e + b811bc5 commit 01822f0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
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

0 comments on commit 01822f0

Please sign in to comment.