Skip to content

Commit

Permalink
chore: support different JWT CSRF cookie names (apache#25891)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar authored and josedev-union committed Jan 22, 2024
1 parent e6f18f8 commit f7ce892
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion superset-frontend/src/setup/setupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions superset/views/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"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__)
Expand Down

0 comments on commit f7ce892

Please sign in to comment.