Skip to content

Commit

Permalink
Added a check for the login page path
Browse files Browse the repository at this point in the history
  • Loading branch information
austin5219 committed Oct 2, 2024
1 parent 4cf8958 commit 1971252
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ui/src/app/login/components/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ const validateAndGetOIDCForPKCE = async (oidcConfig: AuthSettings['oidcConfig'])
export const pkceLogin = async (oidcConfig: AuthSettings['oidcConfig'], redirectURI: string) => {
const {authorizationServer} = await validateAndGetOIDCForPKCE(oidcConfig);

sessionStorage.setItem('return_uri', location.pathname + location.search)
// This sets the return path for the user after the pkce auth flow.
// This is ignored if the return path would be the login page as it would just loop.
if (!location.pathname.startsWith(requests.toAbsURL('/login'))) {
sessionStorage.setItem('return_uri', location.pathname + location.search);
}

if (!authorizationServer.authorization_endpoint) {
throw new PKCELoginError('No Authorization Server endpoint found');
Expand Down Expand Up @@ -156,6 +160,8 @@ export const pkceCallback = async (queryParams: string, oidcConfig: AuthSettings

const returnURI = sessionStorage.getItem('return_uri');

// This returns the user to their previous path if saved in pkcelogin.
// This is to mirror the functionality of the dex auth flow return_url query parameter.
if (returnURI) {
sessionStorage.removeItem('return_uri');
window.location.replace(returnURI);
Expand Down

0 comments on commit 1971252

Please sign in to comment.