-
Notifications
You must be signed in to change notification settings - Fork 16.2k
fix(security): enable AUTH_RATE_LIMITED to work correctly #36195
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(security): enable AUTH_RATE_LIMITED to work correctly #36195
Conversation
When AUTH_RATE_LIMITED = True is set in superset_config.py, the application would fail to start because Flask-AppBuilder's rate limiting logic tried to apply rate limiting to the auth view blueprint, but the blueprint was None in certain initialization contexts (e.g., MCP service's flask_singleton). This fix applies rate limiting directly in Superset's register_views() method after the auth view is created, and prevents the parent's register_views() from attempting to re-apply rate limiting by temporarily disabling the AUTH_RATE_LIMITED config during the super() call. The fix ensures rate limiting works correctly regardless of how many Flask app instances are created (main app, MCP service, etc.).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #36195 +/- ##
===========================================
+ Coverage 0 68.20% +68.20%
===========================================
Files 0 629 +629
Lines 0 46209 +46209
Branches 0 5003 +5003
===========================================
+ Hits 0 31518 +31518
- Misses 0 13446 +13446
- Partials 0 1245 +1245
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:
|
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.
Code Review Agent Run #1cb99e
Actionable Suggestions - 1
-
superset/security/manager.py - 1
- Undefined rate limiting attributes and unsafe config handling · Line 2878-2901
Review Details
-
Files reviewed - 1 · Commit Range:
250f448..250f448- superset/security/manager.py
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- MyPy (Static Code Analysis) - ✔︎ Successful
- Astral Ruff (Static Code Analysis) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at [email protected].
Documentation & Help
villebro
left a comment
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.
I can confirm this works. The temporary disabling of the rate limiting config feels slightly janky, but hey, if it works it works 🙂
- Use getattr pattern instead of hasattr + separate None check for DRYness - Remove .get() on config since AUTH_RATE_LIMITED has default value
|
Investigating CI failures in test-postgres (previous) and test-postgres (next). The errors appear to be database-related (PendingRollbackError, unique constraint violations) rather than config-related. Checking if these are flaky tests or related to the changes. |
Co-authored-by: Joe Li <[email protected]>
Co-authored-by: Joe Li <[email protected]>
SUMMARY
Fixes the
AUTH_RATE_LIMITEDconfiguration to work correctly when set toTrue. Previously, enabling this setting would cause the application to fail during startup.Before this fix:
When
AUTH_RATE_LIMITED = Trueis set insuperset_config.py, the application fails to start with:After this fix:
The application starts successfully with rate limiting properly applied to the auth view.
Root cause:
Flask-AppBuilder's
register_views()method tries to apply rate limiting toself.auth_view.blueprint, but in certain initialization contexts (e.g., MCP service's flask_singleton), the blueprint isNone, causing the error.Solution:
register_views()method after the auth view is createdregister_views()from attempting to re-apply rate limiting by temporarily disablingAUTH_RATE_LIMITEDduring thesuper()callThis ensures rate limiting works correctly regardless of how many Flask app instances are created.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend fix
TESTING INSTRUCTIONS
Before fix (reproduces error):
AUTH_RATE_LIMITED = Trueinsuperset_config.pyPYTHONPATH=. superset run -p 8088After fix (works correctly):
AUTH_RATE_LIMITED = Trueinsuperset_config.pyPYTHONPATH=. superset run -p 8088/login/rapidlyMCP Service test:
AUTH_RATE_LIMITED = TrueandMCP_AUTH_ENABLED = Trueinsuperset_config.pyPYTHONPATH=. superset mcp run --port 5008ADDITIONAL INFORMATION