question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Infinite Loop with url params after redirection from keycloak server

See original GitHub issue

Versions.

The versions for the keycloak angular and the keycloak-js are given below.

Angular version - 8.2.4 keycloak-angular - 7.2.0 keycloak-js - 10.0.1

Repro steps.

After configuring the keycloak as given in the documentation, the site is redirecting to the keycloak page and shows login page. But once logged in, it redirects back to the application and causes infinite redirection loop with url parameters. The redirection flow is given below.

  1. The angular application redirects to keycloak.
  2. Keycloak after authentication redirects back to angular application with session_state, and code values as url parameters.

http://localhost:5000/?state=e3eb1104-4e49-4f35-8277-7a02d10a7ec1&session_state=99826a89-eb5d-48a8-a73c-76cd9b007401&code=85a45a70-f647-4bec-984e-389e410d5757.99826a89-eb5d-48a8-a73c-76cd9b007401.93de3ba7-4a58-418e-893f-8340217592fb 3. The angular application then redirects to root url http://localhost:5000

  1. Once the root url is loaded, the login redirect is triggered to keycloak. And the process repeats again.

I tried to debug this issue. But the redirection seems to happen within keycloak library, and the application code seems to have no control over it.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
bpiogecommented, Sep 3, 2021

For me, it was solved by setting initialNavigation to “enabledNonBlocking” in the parameters of the router module (it was set to “enabledBlocking”).

 RouterModule.forRoot(appRoutes, {
      initialNavigation: 'enabledNonBlocking',
      preloadingStrategy: PreloadAllModules
    })

The only problem is that “enabledBlocking” is required for the server side rendering to work

5reactions
JakubRejzekcommented, Sep 6, 2021

I had this issue too. We later found out that the reason behind it was incorrectly set up keycloak. Add * in weborigins of your realm settings. It solves this issue.

I hope that this works for you too. If not try the solutions above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyCloak Login leads to infinite loop
Now when I access my app through the browser I get redirected to auth/realms/... with the appropriate redirect-url. Thats the expected behaviour ...
Read more >
Keycloak login, infinite loop - Szórádi Balázs - Medium
Based on user logs, the token was successfully retrieved from Keycloak after login, but after redirect back to the application, the refresh of ......
Read more >
[KEYCLOAK-2398] Endless redirect loop in 1.7.0
We upgraded from 1.4.0 to 1.7.0 and got a endless redirect loop after logging in with the keycloak-js adapter.
Read more >
'[keycloak-user] KeycloakOIDCFilter infinite loop after ...
... Subject: [keycloak-user] KeycloakOIDCFilter infinite loop after authentication ... my filter to /secret/index.html but it's still looping the redirect.
Read more >
Keycloak AdminURL infinite redirect loop
Proxying the root (/) instead of /auth · Proxying to http instead of https · Adding proxy-address-forwarding to the http/https listener · Adding...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found