-
Notifications
You must be signed in to change notification settings - Fork 692
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
Loop when refresh token does not return an id token #1188
Comments
Can you help us reproduce this issue? A minimal sample of sorts, or at the least redacted responses, would be helpful. Otherwise it's a bit down to guessing at the root cause. You could try and reconfigure my sample repo against your IDS and see if it happens. If so then I presume it's specific to your IDS, as I haven't seen this problem with IdentityServer4 at all thus far. |
I think the problem is, that IdentityServer4 does include the id-Token in the refresh-response, but azure ad b2c does not. |
Some more information: This answer says, that the Id-Token must not be refreshed: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokenResponse Here is the function, where the timers for the token refresh will be set:
If the refresh token response does not include an Id-Token and the Id-Token is expired, it will be invalid (line 425). Then a new timer will be set. But because the next response does still not include a Id-Token, it is still invalid and e new timer will be set. This is the endless-loop. |
Thanks for the links and the pointers to the code. Clear description, and that scenario makes sense. If the id token is not included (as possible per the spec) then the timers should behave accordingly. In #1185 a similar root cause for a very different issue was noted as well. Very maybe even that issue gets resolved too if we fix things here? |
I have come across this behaviour in a different scenario. |
I also noticed this bug using ABP v5.2.0 and upgrading to rxjs 7.5.5. is there any workaround other than downgrading rxjs? is the problem in this library or with abp? |
Hi, When the refresh works, I get this kind of log in the console:
When the refresh seems to fail, I notice an endless loop on the refresh with this kind of log in the console that pops every ~2 seconds (the timeoutFactor is not respected anymore):
I notice the order of the events is different: I use the following conf points: I also tried to add the scope What can be the cause of that refresh loop? Thanks. |
@jeroenheijmans, is the loop described in my previous post a bug of angular-oauth2-oidc library as you tagged this theme "bug"? If yes, is there any work around to avoid this loop? |
I labelled it a 'bug' after getting the reproducible scenario from the Original Poster of this thread. I've not looked into your post/repro yet, don't know if it's the same thing or something different? |
I don't know if the logs I get are the same as the original poster. I edited my 1st post of this thread because I realized than depending on the lifetime of the tokens (authorization code, refresh token and access token) set in the IDP, the refresh can fail directly at the first refresh or with other values, after a certain amount of refreshs. @jeroenheijmans , what do you think? |
If it can help, for information, in our AuthConfig, I updated the scope attribute from: Then: 2 @jeroenheijmans, there's no endless loop anymore and the refresh are done at the expected times. |
Having the same issue. When the token is refreshed, the id_token is missing in the answer. Even with a changed scope it does not deliver an id_token. Afaik the timer for the access_token is reset when the silentrefresh occurs. The one for the id_token remains untouched(since it is missing in the response). Therefore it tries to refresh the token every second (debounceTimer of 1000 millis) and fails successfully refreshing the id_token. My workaround was to only listen to the access_token expiration. I did that by It worked for me, aslong as I could not identify the problem of the missing id_token. |
This next version will have a config property Also, you could try to not use the automatic timers but call refreshToken() directly in your code when needed, e. g. in an interceptor. |
We use this library in our angular 12 project with azure ad b2c and code flow. After the login we get an access-token and an id-token. After one hour they expires. Then the library does a refresh-token request. In the response of this request the id-token is missing. Because the id-token is expired, it does a new refresh-token request immediately, the id-token is still missing. This loop never ends.
The text was updated successfully, but these errors were encountered: