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

Ensure token refresh is always scheduled #6802

Merged
merged 3 commits into from
Apr 30, 2024
Merged

Ensure token refresh is always scheduled #6802

merged 3 commits into from
Apr 30, 2024

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Apr 30, 2024

There appears to have been an oversight in setting up token refreshes, in particular how/when refreshes are scheduled. In particular the _schedule_refresh function was only ever called when a user was either:

  1. Visiting the application for the first time and going through the whole auth flow
  2. Re-visiting the application for the first time after the tokens expired once
  3. Returning to the application after both the access and refresh tokens expired

In the case where a user was revisiting the application after their token had already been refreshed once we did not schedule another refresh. If you revisited after a long time when your token was already expired you'd be forced through the auth flow again and everything would be fine too but if you got unlucky and visited while a refreshed token was stilled just barely valid you could end up with the token expiring without any refresh having been scheduled. Here we now ensure that we ALWAYS schedule the tokens to be refreshed.

Additionally we also now update the cookies when a user revisits the application ensuring that the access_token, oauth_expiry and refresh_token cookies reflect the latest refresh values. However if a token is refreshed while a session is running these cookies may still be out-of-date until the next time the user visits the application:

Fixes #6684

panel/auth.py Outdated Show resolved Hide resolved
@philippjfr philippjfr merged commit 2e26d6d into main Apr 30, 2024
13 of 14 checks passed
@philippjfr philippjfr deleted the token_refresh_fix branch April 30, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

oauth_expiry cookie provides incorrect information when using refresh_token
2 participants