fix(auth): guest token takes priority over active session for embedded dashboards#38950
fix(auth): guest token takes priority over active session for embedded dashboards#38950michael-s-molina wants to merge 1 commit into
Conversation
Code Review Agent Run #c56cccActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (99.85%) is below the target coverage (100.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
User description
SUMMARY
When a user has an active Superset session (e.g. they are logged in as themselves in another tab) and visits an embedded dashboard that uses a guest token, their session identity was silently taking precedence over the guest token identity. This caused 403 errors for users whose real account does not have access to the embedded dashboard's underlying datasets.
Root cause: Flask-Login's
_load_user()checks the session first. If a_user_idis found in the session, it loads that user and setsg._login_user, then stops — therequest_loader(where guest token auth lives) is never reached. Flask-Login's_get_user()only calls_load_user()ifg._login_useris not already set, so preemptively setting it before the session is consulted is the correct fix.Fix: Register a
before_requesthook increate_login_managerthat checks for a guest token on every request. If a valid token is found, it setsg._login_userto the guest user before Flask-Login runs. Since_get_user()short-circuits wheng._login_useris already set, the session is never consulted for requests that carry a guest token.The existing
request_loader(request_loadermethod) is kept as-is; it still handles the case where there is no active session at all.TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
CodeAnt-AI Description
Guest tokens now take priority over an active Superset session for embedded dashboards
What Changed
Impact
✅ Fewer embedded dashboard access errors✅ Fewer 403s for logged-in users viewing shared dashboards✅ Clearer embedded dashboard access behavior💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.