chore: support different JWT CSRF cookie names (#25891)

This commit is contained in:
Daniel Vaz Gaspar 2023-11-14 14:01:08 +00:00 committed by GitHub
parent 5def416f63
commit 007d22199d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -18,13 +18,18 @@
*/
import { SupersetClient, logging, ClientConfig } from '@superset-ui/core';
import parseCookie from 'src/utils/parseCookie';
import getBootstrapData from 'src/utils/getBootstrapData';
const bootstrapData = getBootstrapData();
function getDefaultConfiguration(): ClientConfig {
const csrfNode = document.querySelector<HTMLInputElement>('#csrf_token');
const csrfToken = csrfNode?.value;
// when using flask-jwt-extended csrf is set in cookies
const cookieCSRFToken = parseCookie().csrf_access_token || '';
const jwtAccessCsrfCookieName =
bootstrapData.common.conf.JWT_ACCESS_CSRF_COOKIE_NAME;
const cookieCSRFToken = parseCookie()[jwtAccessCsrfCookieName] || '';
return {
protocol: ['http:', 'https:'].includes(window?.location?.protocol)

View File

@ -122,6 +122,7 @@ FRONTEND_CONF_KEYS = (
"ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT",
"NATIVE_FILTER_DEFAULT_ROW_LIMIT",
"PREVENT_UNSAFE_DEFAULT_URLS_ON_DATASET",
"JWT_ACCESS_CSRF_COOKIE_NAME",
)
logger = logging.getLogger(__name__)