-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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
fix(embed): fix server error due to breaking change on flask-login #22462
Conversation
5cb0e96
to
f44a840
Compare
Codecov Report
@@ Coverage Diff @@
## master #22462 +/- ##
==========================================
- Coverage 67.10% 65.59% -1.51%
==========================================
Files 1869 1869
Lines 71580 71589 +9
Branches 7806 7822 +16
==========================================
- Hits 48031 46959 -1072
- Misses 21521 22601 +1080
- Partials 2028 2029 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Has this been merged & released? |
ok taking back my comment above, this is not related to this PR, but rather to other security settings. I confirm that the patch is working and fixing my issue on latest code base |
Thanks for verifying the fix @pythys!
Not yet @adimyth. Let me bump this PR on the community Slack. |
Due to a breaking change in Flask-Login (maxcountryman/flask-login#378) the code for logging in our the AnonymousUser breaks. Unfortunately, Flask-Login not only renames the method we need, but also makes it quasi-private. We can switch to a different public util function Flask-Login offers since at least version 0.3.0. In all versions I checked it essentially executes the same steps as `reload_user(...)` did (it additionally signals the login event internally, which shouldn't cause issues). Fixes apache#21987
Thanks very much, @Usiel Let me know when you bump this PR in community slack, I'll follow the thread & provide support if needed |
This appears to be a regression from #22355 . Ping @EugeneTorap , can you check this? Edit: this seems to predate the bump PR, but it would be good to ensure it's valid for the new version |
Yes, it's regression bug from my PR because we don't have unit tests for the logic. |
@Usiel Can you add the unit tests for it? |
@EugeneTorap looking more closely it seems it's the missing pinning that was the problem. So we should have restricted to |
@villebro We use only ´"flask-login==0.6.0"´ in setup.py because 0.6.2 has breaking changes for superset. |
f44a840
to
be46675
Compare
Sure, I added an integration test which fails with the previous implementation and |
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.
Thanks so much for this fix + the added tests, a much needed improvement to ensure embedded is properly maintained going forward 👍 One minor nit, but I'm happy merging as-is.
Looking forward to this PR being merged & being shipped in the next release! |
If assuming SemVer 2.0, this is not true, as releases in Major version |
0717fb7
to
c0b3679
Compare
Strictly speaking this is true, but in my experience most patch releases in the 0 major version tend to be API stable. |
SUMMARY
Due to a breaking change in Flask-Login (maxcountryman/flask-login#378) the code for logging in an
AnonymousUser
breaks for dashboard embedding.Unfortunately, Flask-Login not only renames the method we need, but also makes it quasi-private. We can switch to a different public util function Flask-Login offers since at least version 0.3.0. In all versions I checked it essentially executes the same steps as
reload_user(...)
did (it additionally signals the login event internally, which shouldn't cause issues).Fixes #21987, #21146
TESTING INSTRUCTIONS
For any Flask-Login>=0.3.0,<0.7.0:
EMBEDDED_SUPERSET
insuperset/config.py
Expected: 200 OK with some valid HTML
(Before we would fail with a 500 for any Flask-Login>=0.5.0)
ADDITIONAL INFORMATION
cc @suddjian: Thanks for building this! Tagging you for better visibility and in case I missed anything. Btw, I noticed that
g.user
and theuser
on thectx
is actually set to anAnonymousUser
instance before doing anything in the endpoint; I believe that's some Flask-Login fallback logic. I'm assuming there is some circumstance, some case, where this might not happen and that is why we added the bit of code previously? (That's why I propose to replace it instead of removing it in this PR.)