-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
chore: allow machine auth to generate CSRF token #26003
chore: allow machine auth to generate CSRF token #26003
Conversation
superset/utils/machine_auth.py
Outdated
@@ -143,6 +144,31 @@ def get_auth_cookies(user: User) -> dict[str, str]: | |||
|
|||
return cookies | |||
|
|||
@staticmethod | |||
def get_auth_cookie_and_csrf_token(user: User) -> tuple[dict[str, str], str]: |
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.
We could check for app.config["WTF_CSRF_ENABLED"]
here and DRY the code a bit more by removing get_auth_cookies
…e/machine_auth_gen_csrf_token
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #26003 +/- ##
==========================================
- Coverage 69.19% 69.18% -0.01%
==========================================
Files 1944 1944
Lines 75927 75932 +5
Branches 8451 8451
==========================================
+ Hits 52534 52537 +3
- Misses 21208 21210 +2
Partials 2185 2185
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
It's related to #28706 |
The celery task get permissions through machine_auth.
The 'cache-warmup' task needs to call the '/api/v1/chart/warm_up_cache' endpoint .However, this endpoint is non GET requests and is therefore protected by CSRF.
Hence, when machine_auth retrieves the auth cookies, it also needs to generate a CSRF token.
This ensures that the Celery task can operate successfully.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION