-
Notifications
You must be signed in to change notification settings - Fork 436
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
[Question]: Endless Redirect Loop After Authentication in Standalone Angular App #2045
Comments
@arharutyu after moving from version The new property Setting this property to Symptomy of the problem seems to be the same, but not sure if the root cause is the same, but I thought it is worth sharing. |
This solved my problem too. @spunzmann how did you discover that ? |
Hello @arharutyu, is this maybe similar to my issue #2040? |
@spunzmann , how do you set OpenIdConfiguration.checkRedirectUrlWhenCheckingIfIsCallback to false? |
@leopoliveira I simply debugged my application with the browsers dev tools and eventually figured it out. I got lucky I guess ;-) @jaigtz88 the property |
I have the same issue with 18.0.2. Coming from 17.x with a simple ng update …@18 yielded a broken login. I can confirm that the first steps work properly. The service requests the code from the OIDC issuer, also queries config via HTTP and does not proceed any further. With the property set to false it takes the issued code and fetches the token, too. It gets even weirder with a filled localstorage. Since that token is very likely expired it gets loaded instead and it looks as if the user is not logged in. This behavior is very hard to track and it took me 2 days to find this issue. I am curious, too, how this could slip through testing. Users of this library will not test this but use a mock for the service instead. |
As this issue cropped up when I was on a timeline and needed to implement redirect to the requested URL the user is accessing prior to login I went ahead with a workaround. By the time @spunzmann commented I had switched to dynamically loading config and for some reason their suggestion wasn't working for me either. To avoid the endless redirect loop
This is the relevant code I used in case it's useful for others:
Updated AuthService (relevant functions only):
|
What Version of the library are you using?
18.0.2
Description:
I'm using the angular-auth-oidc-client library in my standalone Angular app (version 18.2.8), with no Angular modules. When I call checkAuth() at the app entry point (app.component.ts), the following issue occurs:
Expected Behavior:
After successful authentication, the user should be redirected to the originally requested protected route, not stuck in a redirect loop.
Current Behavior:
After authentication, the app is stuck in a redirect loop between /callback and IDP.
Steps to Reproduce:
Environment:
Angular version: 18.2.8
angular-auth-oidc-client version: 18.0.2
Browser: Chrome or Edge
What I've Tried:
Ensured the callback route is correctly configured in the routing module.
Tried adding logic in the callback component to navigate to the required route, but it still results in the redirect loop.
Questions:
Why is this endless redirect loop happening?
How can I ensure that the callback works as expected and navigate to the protected route after authentication?
Code Snippets:
Relevant code snippets provided, further can be provided if needed!
app.routes.ts
app.component.ts
auth.service.ts
The text was updated successfully, but these errors were encountered: