Skip to content

Commit

Permalink
Merge pull request #152 from adrienne-deriv/fix-logout-redirect-uri
Browse files Browse the repository at this point in the history
Fix logout redirect uri wrong url reconstruction
  • Loading branch information
adrienne-deriv authored Feb 7, 2025
2 parents f977b5d + e409673 commit 81e03da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/constants/__tests__/urls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('URLs', () => {

const oauthUrl = getOauthUrl();

expect(oauthUrl).toBe('https://qa.deriv.com/oauth2/authorize?app_id=67890&l=EN&&brand=deriv');
expect(oauthUrl).toBe('https://qa.deriv.com/oauth2/authorize?app_id=67890&l=EN&brand=deriv');
});

it('should return the default OAuth URL if appId and serverUrl are not set', () => {
Expand All @@ -136,7 +136,7 @@ describe('URLs', () => {

const oauthUrl = getOauthUrl();

expect(oauthUrl).toBe('https://qa.deriv.com/oauth2/authorize?app_id=67890&l=EN&&brand=deriv');
expect(oauthUrl).toBe('https://qa.deriv.com/oauth2/authorize?app_id=67890&l=EN&brand=deriv');
});
});

Expand Down
19 changes: 10 additions & 9 deletions src/oidc/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const requestOidcAuthentication = async (options: RequestOidcAuthenticati

await userManager.signinRedirect({
extraQueryParams: {
brand: "deriv"
brand: 'deriv',
},
});
return { userManager };
Expand Down Expand Up @@ -287,14 +287,15 @@ export const OAuth2Logout = async (options: OAuth2LogoutOptions) => {
const oidcEndpoints = localStorage.getItem('config.oidc_endpoints') || '{}';

let logoutUrl = getOAuthLogoutUrl() || JSON.parse(oidcEndpoints).end_session_endpoint;
const userManager = await createUserManager({
redirectCallbackUri: options.redirectCallbackUri,
postLogoutRedirectUri: options.postLogoutRedirectUri,
});
const userState = await userManager.getUser();
if (userState?.id_token) {
logoutUrl += `?id_token_hint=${userState.id_token}&post_logout_redirect_uri${options.postLogoutRedirectUri}`;
}
// NOTE: Comment this out once front channel is implemented
// const userManager = await createUserManager({
// redirectCallbackUri: options.redirectCallbackUri,
// postLogoutRedirectUri: options.postLogoutRedirectUri,
// });
// const userState = await userManager.getUser();
// if (userState?.id_token) {
// logoutUrl += `?id_token_hint=${userState.id_token}&post_logout_redirect_uri=${options.postLogoutRedirectUri}`;
// }

const cleanup = () => {
const iframe = document.getElementById('logout-iframe') as HTMLIFrameElement;
Expand Down

0 comments on commit 81e03da

Please sign in to comment.