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

[Bug]: Query params are not restored after authentication #2042

Open
d-eder opened this issue Nov 11, 2024 · 0 comments
Open

[Bug]: Query params are not restored after authentication #2042

d-eder opened this issue Nov 11, 2024 · 0 comments

Comments

@d-eder
Copy link

d-eder commented Nov 11, 2024

Version

18.0.2

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Steps to reproduce the behavior

1. Open your browser and add some custom query parameters
2. Add some logging: console.log("URL-Before", window.location.href);
3. Call the function `this.oidcSecurityService.checkAuth`
4. Add another logging:  console.log("URL-After", window.location.href);

You can see that href url has changed and that the query params are gone.

A clear and concise description of what you expected to happen.

We use query params to store the current table state (searching, sorting). With the query params it is possible that you can bookmark the current page including the table state.

However, after calling `checkAuth` - all query params are lost and I get redirected to the root page.

Additional context

Our auth implementation:

  async authenticate(): Promise<void> {
    if (!await this.checkAuth()) {
      this.oidcSecurityService.authorize();
    } else {
      this.authenticated.set(true);
    }
  }

  private async checkAuth() {
    const auth = await firstValueFrom(this.oidcSecurityService.checkAuth();
    console.log("AUTH", auth);
    return auth.isAuthenticated;
}

Our OpenIdConfigutation:

private toOpenIdConfig(securityConfig: SecurityConfigDto) {
    return {
      authority: securityConfig.authority,
      clientId: securityConfig.clientId,
      scope: 'openid profile email offline_access',
      responseType: 'code',
      redirectUrl: window.location.origin,
      postLogoutRedirectUri: window.location.origin,
      silentRenew: true,
      useRefreshToken: true,
      secureRoutes: [environment.apiUrl],
      ignoreNonceAfterRefresh: true,
      logLevel: LogLevel.Warn,
    } as OpenIdConfiguration;
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant