-
Notifications
You must be signed in to change notification settings - Fork 44
fix(token): Implement locking for token refresh #1277
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
Conversation
1c543a7 to
f8cc3cf
Compare
julien-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. Code looks good. A few questions then I'll make some tests and we're good to go.
f8cc3cf to
c6da408
Compare
|
You're right. The token refresh involves network requests to the OAuth2 provider, which typically takes 200-500ms or more. The 100ms wait was pointless because Process A will still be in the middle of the HTTP call... I've pushed a retry mechanism to accomplish this : Process A:
Process B:
This (should) prevent both the race condition and unnecessary duplicate token refreshes. |
c6da408 to
5955dea
Compare
|
I've just found out that this is a bit of a duplicate of #1178 but with another approach... sorry! 🙈 |
|
Please don't be sorry. I'm really not sure writing a lock in the Php session is a viable solution because I don't exactly know when Symfony reads and writes the session data. So we might get outdated data when reading the lock. Using the lock mechanism like you did + the session ID as identifier seems like a better approach. |
julien-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wdyt?
5955dea to
cc6570d
Compare
cc6570d to
fe548e1
Compare
Signed-off-by: Git'Fellow <[email protected]>
julien-nc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 💙
Fix #1175
Added locking mechanism to prevent race conditions during token refresh.
Enhanced error handling and logging for token refresh process.
The fix uses
ILockingProviderto ensure atomic token refresh: