singingwolfboy / flask-dance

Doing the OAuth dance with style using Flask, requests, and oauthlib.
https://pypi.python.org/pypi/Flask-Dance/
MIT License
1.01k stars 158 forks source link

account for overrides when generating new token #421

Open ryan-s opened 1 year ago

ryan-s commented 1 year ago

If the user has overridden the OAuth model, the automatic token refresh will fail if the user has defined columns that are not nullable. The common use case for this seems to be the instance where the author has associations with multiple providers. The commit will fail because the provider_user_id and the provider_username are not carried over to the new token.

The proposed solution will end up added an additional query to get the existing entry and copying over any fields that are not nullable into the new token.

codecov[bot] commented 1 year ago

Codecov Report

Merging #421 (de5a6a5) into main (27add75) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #421      +/-   ##
==========================================
+ Coverage   96.35%   96.37%   +0.02%     
==========================================
  Files          37       37              
  Lines        1070     1077       +7     
==========================================
+ Hits         1031     1038       +7     
  Misses         39       39              
Files Changed Coverage Δ
flask_dance/consumer/storage/sqla.py 92.30% <100.00%> (+0.48%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

ryan-s commented 1 year ago

Looks like this is working now, however I was not able to get the tests to pass locally without hard coding in adding the test state into oauth2.py. Seems like theres some kind of issue in Flask where its not preserving the session that gets created during the test.