You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "devyash786 (via GitHub)" <gi...@apache.org> on 2025/03/19 12:00:44 UTC

[D] Even though csrf token is being passed, response is [superset]

GitHub user devyash786 created a discussion: Even though csrf token is being passed, response is

Even though csrf token is being passed, response is 
 
    "errors": [
        {
            "message": "400 Bad Request: The CSRF session token is missing.",
            "error_type": "GENERIC_BACKEND_ERROR",
            "level": "error",
            "extra": {
                "issue_codes": [
                    {
                        "code": 1011,
                        "message": "Issue 1011 - Superset encountered an unexpected error."
                    }
                ]
            }
        }
    ]
}

GitHub link: https://github.com/apache/superset/discussions/32751

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Even though csrf token is being passed, response is

<!-- Answer -->
When the CSRF token handling works locally but not on the server, consider the following potential differences and solutions:

1. **Server Configuration**: Check if there are any differences in the server configuration compared to your local environment that could affect CSRF token handling. This includes settings related to session management, security, and network configurations.

2. **CSRF Token Expiration and Validation**: Ensure that the server-specific settings for CSRF token expiration and validation are correctly configured. The default timeout for CSRF tokens in Superset is one week, which can be adjusted using the `WTF_CSRF_TIME_LIMIT` setting <sup>[[1]](https://github.com/apache/superset/blob/a49a15f990176c8736ad67d06f74e6eb30b612e4/superset/config.py)</sup>.

3. **Headers and Proxies**: Verify that any middleware or proxy on the server is not altering or stripping headers, including the CSRF token. Ensure that all necessary headers, such as `X-CSRFToken` and `Referer`, are correctly set and transmitted.

4. **Session Persistence**: Ensure that session persistence is correctly configured on the server. Differences in session management between local and server environments can lead to issues with CSRF token handling.

5. **Network and Security Settings**: Check for any specific network or security settings on the server that could interfere with CSRF token transmission or validation.

By addressing these areas, you should be able to identify and resolve the discrepancies between your local and server environments regarding CSRF token handling.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b2291918-c06e-452a-a529-73826be7517c?feedback_type=other)</sup>


GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12551691

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "devyash786 (via GitHub)" <gi...@apache.org>.
GitHub user devyash786 added a comment to the discussion: Even though csrf token is being passed, response is

@dosu
Getting this error..
2025-03-19 12:35:49,203:INFO:flask_wtf.csrf:The CSRF session token is missing.
2025-03-19 12:35:49,203:WARNING:superset.views.error_handling:Refresh CSRF token error
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 261, in protect
    validate_csrf(self._get_csrf_token())
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 103, in validate_csrf
    raise ValidationError("The CSRF session token is missing.")
wtforms.validators.ValidationError: The CSRF session token is missing.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1482, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1974, in preprocess_request
    rv = self.ensure_sync(before_func)()
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 229, in csrf_protect
    self.protect()
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 264, in protect
    self._error_response(e.args[0])
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 307, in _error_response
    raise CSRFError(reason)
flask_wtf.csrf.CSRFError: 400 Bad Request: The CSRF session token is missing.
2025-03-19 12:35:49,203:WARNING:superset.views.error_handling:HTTPException
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 261, in protect
    validate_csrf(self._get_csrf_token())
  File "/usr/local/lib/python3.10/site-packages/flask_wtf/csrf.py", line 103, in validate_csrf
    raise ValidationError("The CSRF session token is missing.")

GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12551437

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "devyash786 (via GitHub)" <gi...@apache.org>.
GitHub user devyash786 added a comment to the discussion: Even though csrf token is being passed, response is

@Dosu
We have try running in local, it was working but not working in servers

GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12551650

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Even though csrf token is being passed, response is

<!-- Answer -->
To resolve the "400 Bad Request: The CSRF session token is missing" error, even though the CSRF token is being passed, ensure the following:

1. **Headers Configuration**: Verify that all required headers are present, including the CSRF token and the Referer header. The Referer header must be properly set for HTTPS requests.

2. **CSRF Token Implementation**: Confirm that the CSRF token is correctly fetched from `/api/v1/security/csrf_token/` and is properly included in the request headers. The `SupersetClientClass` in Apache Superset ensures that the CSRF token is included in the headers as `X-CSRFToken` if it is available.

3. **Initialization**: Make sure that the `SupersetClientClass` is properly initialized with the CSRF token by calling `client.getCSRFToken()` before making requests. This ensures that the CSRF token is fetched and set in the headers.

If these components are correctly configured and the error persists, there may be an issue with how the CSRF token is being included or validated in the request. Double-check the token's retrieval and inclusion process. Additionally, ensure that the `ensureAuth` method is called to verify authentication and token presence before making requests <sup>[[1]](https://github.com/apache/superset/discussions/31465)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts)</sup>.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/56300339-e53c-4f02-b5f2-7dceedd8f2f5?feedback_type=other)</sup>


GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12550857

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Even though csrf token is being passed, response is

<!-- Answer -->
Hey @devyash786! It sounds like you're diving into the world of Helm charts. While I can help with technical questions, bugs, and engineering knowledge, I'm not equipped to assist with Helm chart deployments specifically. If you think I should be able to help with this, feel free to reach out to the [Dosu Team](mailto:customersuccess@dosu.dev). They'll be happy to hear your feedback!


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5a50d70e-d874-4d40-acfd-0932fd600808?feedback_type=other)</sup>


GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12599608

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Even though csrf token is being passed, response is

<!-- Answer -->
The error message "The CSRF session token is missing" indicates that the CSRF token is not being correctly included in the session or request. Here are some steps to troubleshoot and resolve this issue:

1. **Verify CSRF Token Retrieval**: Ensure that the CSRF token is being correctly fetched from the `/api/v1/security/csrf_token/` endpoint. The `SupersetClientClass` should handle this process, and the token should be stored and included in subsequent requests <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/src/connection/SupersetClientClass.ts)</sup>.

2. **Check Headers**: Confirm that the CSRF token is included in the request headers as `X-CSRFToken`. Also, ensure that other necessary headers, such as the `Referer` header, are correctly set.

3. **Session Management**: Make sure that the session is properly maintained between requests. If the session is not persistent, the CSRF token might not be stored correctly.

4. **CSRF Token Expiry**: Check if the CSRF token has expired. The default timeout for CSRF tokens in Superset is one week, but this can be configured with the `WTF_CSRF_TIME_LIMIT` setting <sup>[[2]](https://github.com/apache/superset/blob/a49a15f990176c8736ad67d06f74e6eb30b612e4/superset/config.py)</sup>.

5. **Error Handling**: The `refresh_csrf_token` error handler in Superset logs a warning and redirects to the login page if the CSRF token is missing or expired. Ensure that this handler is correctly configured to manage CSRF errors <sup>[[3]](https://github.com/apache/superset/blob/master/superset/views/error_handling.py)</sup>.

By following these steps, you should be able to identify and resolve the issue with the missing CSRF session token.


<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*

---
<sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/fd1a08ec-dfe5-4222-8729-30ea60dec1f7?feedback_type=other)</sup>


GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12551467

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "devyash786 (via GitHub)" <gi...@apache.org>.
GitHub user devyash786 added a comment to the discussion: Even though csrf token is being passed, response is

@dosu
I am using helm chart to deploy.

GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-12599601

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [D] Even though csrf token is being passed, response is [superset]

Posted by "edwardzhanged (via GitHub)" <gi...@apache.org>.
GitHub user edwardzhanged added a comment to the discussion: Even though csrf token is being passed, response is

Same error. Seems good in Postman.

GitHub link: https://github.com/apache/superset/discussions/32751#discussioncomment-14537488

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org