Vitor-Avila opened a new pull request, #40071:
URL: https://github.com/apache/superset/pull/40071

   ### SUMMARY
   This PR fixes a very rare race condition that could happen with the OAuth2 
flow. When loading a dashboard powered by a DB connection authenticated with 
OAuth2, multiple requests would hit `get_oauth2_access_token`, load the 
existing OAuth2 token for the user, and if needed call `refresh_oauth2_token`. 
We currently have a lock to prevent several requests from hitting 
`refresh_oauth2_token` in parallel, however there was still an edge case where:
   1. Request A is fired, hits `get_oauth2_access_token`, loads the token, 
check that it's expired and accesses `refresh_oauth2_token` passing this token, 
acquiring a lock.
   2. Request B is fired, hits `get_oauth2_access_token` and loads the token.
   3. Request A completes `refresh_oauth2_token` and delete the token as part 
of the process, releasing the lock.
   4. Request B hits `refresh_oauth2_token` passing the token loaded in step 2.
   5. When trying to access one of the token properties, the token is actually 
deleted.
   
   The fix is to get the token again in `refresh_oauth2_token`.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   No UI changes.
   
   ### TESTING INSTRUCTIONS
   Tests updated and new test added.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to