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]: Silent refresh fails using localStorage when multiple tabs trying to refresh at the same time #1838

Open
Coldfen opened this issue Sep 13, 2023 · 15 comments
Assignees
Labels

Comments

@Coldfen
Copy link

Coldfen commented Sep 13, 2023

Version

16.0.0

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

myConfigId - silent renew failed! Error: Error: authorizedCallback, token(s) validation failed, resetting.

Steps to reproduce the behavior

1) Set up OIDC Code Flow PKCE using refresh tokens (used 'ng add angular-auth-oidc-client')

2) Set up custom storage using localStorage (used example from https://angular-auth-oidc-client.com/docs/documentation/custom-storage)

3) To speed up testing, setup your authority to have short lived access and refresh tokens. (i.e. 30 - 50 seconds) 

4) Login using one browser [chrome] tab (i.e. this.oidcSecurityService.authorize()). Open console and verify refresh is working

5) Open a few more tabs. Open console and verify they are authorized and refreshing (in my case i open 6 or more)

6) Wait until error occurs. It shouldn't take long - usually 2-20 minutes with 30 - 40 seconds tokens. Open more tabs if needed.

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

Access token should refresh successfully and all tabs remain authorized

Additional context

The same problem was described in #1662

image

A temporary solution does not suit me well, because my token functions for 300 seconds.

My config:
image

AuthConfigModule added to the imports of the main AppModule.

@joewIST
Copy link

joewIST commented Sep 19, 2023

Experiencing the same issue. Any help appreciated.

@CraigGP1
Copy link

Same issue.

@Ghostbird
Copy link

We're encountering issues with this fairly often too. If there's a solution at the library level, that would be great.

@joewIST
Copy link

joewIST commented Sep 20, 2023

Not sure if you are experiencing any of the issues found here as well? #1753

@Ghostbird
Copy link

Ghostbird commented Sep 21, 2023

No, not as far as I know. The trick mentioned in #1662 (comment) is something I'm going to try, where the renewTimeBeforeTokenExpiresInSeconds gets a random number. That won't fix it, but may significantly reduce the problem.

@joewIST
Copy link

joewIST commented Sep 21, 2023

Good luck. We tried that in the past but it didn't fix our issue.

@joewIST
Copy link

joewIST commented Sep 21, 2023

We tried that but unfortunately it doesn't resolve our issue.

@lemonCMS
Copy link

lemonCMS commented Apr 2, 2024

Is there any progress on this issue?

@FabianGosebrink
Copy link
Collaborator

FabianGosebrink commented Apr 2, 2024

The cleanest solution would be to queue up the refreshes to guarantee a sequential order🤔🤔🤔 If that is possible. Have to test, but afair the tab gets a new instance of the lib, so basically we have to distinguish between what is being renewed currently. Maybe we can move the renewal information to the specific entry in the LS. Wdyt?

@sebastiandenis
Copy link

sebastiandenis commented Apr 4, 2024

We have the same issue :/ (v. 16.0.1)

@Ghostbird
Copy link

@FabianGosebrink I think most proposed workarounds are trying to achieve this. I tried a random renewTimeBeforeTokenExpiresInSeconds for example, assuming that it would sequence the refreshes, but that didn't work.

@sebastiandenis
Copy link

@FabianGosebrink is there any chance to fix this anytime soon? We've tried many workarounds, but it seems that you can't do too much from the outside of the lib. When this error occurs, the auth data is being reset in the local storage and it affects all the tabs.

@FabianGosebrink
Copy link
Collaborator

I would love to but lacking of time :( As soon as I got time I can try to fix this.

@jugarpeupv
Copy link

Hi @FabianGosebrink, could you give us a hint in how you think this should be implemented?

I was looking at the implementation suggested on the manfredsteyer/angular-oauth2-oidc using the Lock API

manfredsteyer/angular-oauth2-oidc#1423

Trying to replicate it on this library, but i am currently stuck on linking this library into my application locally with this error. I don't have a clue why this might be happening

image

Anyway, if you could share your thoughts on this approach, thank you in advanced ^^

@joewIST
Copy link

joewIST commented Sep 8, 2024

Hi, has anyone found a reliable workaround for this? We are still stuck with the issue on v18. @FabianGosebrink Is this something that is planned in the near future? Thanks again for your help.

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

8 participants