Skip to content

[Question]: Automatic redirect to original url after authentication #2070

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

Open
MatthiasHuygelen opened this issue Jan 21, 2025 · 0 comments
Open
Labels

Comments

@MatthiasHuygelen
Copy link

What Version of the library are you using?
19.0.0
...

info
I am implementing authentication using Azure B2C. After successfully logging in the application redirects back to the original location instead of /draw as intended.

The configuration values stored in the browser's storage seem correct, and the authentication tokens are available. However:

  • isAuthenticated is false (as observed from the oidcSecurityService.checkAuth() log).
  • The isAuthenticated$ observable reports true.

When I try accessing /draw again, the same behavior occurs.

After enabling withDebugTracing I also see the following error

Router Event: NavigationCancel
router.mjs:7168 NavigationCancel(id: 1, url: '/draw?state=014ce5c0396f759a28378b99548a242f2f....&code={CODE}')
router.mjs:7169 NavigationCancel {id: 1, url: '/draw?state=014ce5c0396f759a28378b99548a242f2f....', reason: '', code: 3, type: 2}
chunk-RTJCVXYN.js?v=88d6ca69:sourcemap:5936 ERROR Error: could not find matching config for state 014ce5c0396f759a28378b99548a242f2f....

Implementation

export const authConfig: PassedInitialConfig = {
  config: {
    authority:
      'https://{APPLICATION}.b2clogin.com/{APPLICATION}.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_SIGN_IN_SIGN_UP',
    authWellknownEndpointUrl:
      'https://{APPLICATION}.b2clogin.com/{APPLICATION}.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_SIGN_IN_SIGN_UP',
    redirectUrl: `${window.location.origin}/draw`,
    postLogoutRedirectUri: window.location.origin,
    unauthorizedRoute: '/unauthorized',
    clientId: '{CLIENT_ID}',
    scope: 'openid profile offline_access', 
    responseType: 'code',
    silentRenew: true,
    useRefreshToken: true,
    autoUserInfo: false,
    issValidationOff: false,
    logLevel: LogLevel.Debug,
    checkRedirectUrlWhenCheckingIfIsCallback: false,
    customParamsAuthRequest: {
      prompt: 'login', 
    },
  },
};
{
    path: 'draw',
    canActivateChild: [autoLoginPartialRoutesGuard],
    children: [
            ...
    ],
  },

Question
Am I missing any settings or is this a bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant