Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.
Some visualization tools (e.g., custom front-end applications) can pass access tokens based
on the JSON Web Token (JWT) standard to Cube. These tokens can be either generated
by these applications or obtained from an identity provider. Cube then validates these tokens.The diagram below shows how it works during the request processing in Cube:
Cube allows you to provide your own JWT verification logic. You can use the
check_auth configuration option to verify a JWT and set the security context.A typical use case would be:
A web server serves a page which needs to communicate with the Cube API.
The web server generates a JWT. The
server includes the token in the page or provides the token to
the frontend via an XHR request. The token is then stored in the local storage or
a cookie.
The token is used for calls to the Cube API.
The token is received by Cube, and verified using any available JWKS (if configured)
Once decoded, the token claims are injected into the security
context.
In development mode, the token is not required for authorization. JWT
verification on this API is on unless Cube is in
development mode,
which is enabled by CUBEJS_DEV_MODE=true — or, when you embed
@cubejs-backend/server-core directly, by the devServer option. NODE_ENV has no
effect on it. A custom check_auth that
rejects unauthenticated requests enforces verification either way.Verification is therefore on by default everywhere, including under cubejs server,
the official Docker images and a bare embedded server. Development mode also
exposes Playground’s unauthenticated endpoints, which hand out and mint valid tokens
carrying any security context, signed with your API secret. This is
intentional — development mode is designed for local development machines only. Never
use it in production, and using it in the Cube cloud platform is highly discouraged
because it bypasses the platform’s security model.You can still pass a token in development mode to set a security
context.
Generating JSON Web Tokens
Authentication tokens are generated based on your API secret. Cube CLI generates
an API Secret when a project is scaffolded and saves this value in the .env
file as CUBEJS_API_SECRET.You can generate two types of tokens:
Without security context, which will mean that all users will have the same
data access permissions.
With security context, which will allow you to implement role-based security
models where users will have different levels of access to data.
It is considered best practice to use an exp expiration claim to limit the
lifetime of your public tokens. Learn more in the JWT docs.
You can find a library to generate JWTs for your programming language
here.In Node.js, the following code shows how to generate a token which will expire
in 30 days. We recommend using the jsonwebtoken package for this.
Then, in a web server or cloud function, create a route which generates and
returns a token. In general, you will want to protect the URL that generates
your token using your own user authentication and authorization:
app.use((req, res, next) => { if (!req.user) { res.redirect("/login") return } next()})app.get("/auth/cubejs-token", (req, res) => { res.json({ // Take note: Cube expects the JWT payload to contain an object! token: jwt.sign(req.user, process.env.CUBEJS_API_SECRET, { expiresIn: "1d" }) })})
Then, on the client side, (assuming the user is signed in), fetch a token from
the web server:
You can optionally store this token in local storage or in a cookie, so that you
can then use it to query the Cube API.
Using JSON Web Key Sets
Looking for a guide on how to connect a specific identity provider? Check out
our recipes for using Auth0 or AWS
Cognito with Cube.
As mentioned previously, Cube supports verifying JWTs using industry-standard
JWKS. The JWKS can be provided either from a URL, or as a JSON object conforming
to JWK specification RFC 7517 Section 4, encoded as a string.
Once a key is configured with jwt.key, jwt.jwkUrl,
CUBEJS_JWT_KEY, or
CUBEJS_JWK_URL,
Cube verifies tokens only against that key. Tokens signed with
CUBEJS_API_SECRET
or CUBEJS_API_SECRETS
are rejected with 403 Invalid token; there is no fallback to the API secret.
When using a JWKS URL, each token must also carry a kid header that matches a
key in the set.To accept both kinds of tokens, write a custom check_auth
that verifies each token against the right key.In the Cube cloud platform, personal Core Data API tokens
keep working with JWKS configured: they are validated by the platform before
JWT verification runs.
Using a key as a JSON string
Add the following to your cube.js configuration file:
Or configure the same using environment variables:
CUBEJS_JWK_URL='<URL_TO_JWKS_JSON>'
Verifying claims
Cube can also verify the audience, subject and issuer claims in JWTs. Similarly
to JWK configuration, these can also be configured in the cube.js
configuration file:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Cube Documentation","colors":{"primary":"#5339CF","light":"#A5A3FF","dark":"#716EEE"},"logo":{"light":"https://mintcdn.com/cubed3/wCTntgEXVYYYnx4l/logo/light.svg?fit=max\u0026auto=format\u0026n=wCTntgEXVYYYnx4l\u0026q=85\u0026s=8bbf45ba64eac6116629064fac55aad7","dark":"https://mintcdn.com/cubed3/wCTntgEXVYYYnx4l/logo/dark.svg?fit=max\u0026auto=format\u0026n=wCTntgEXVYYYnx4l\u0026q=85\u0026s=d8fa230950c8c63b3c2f88d2768694d0"},"favicon":"https://mintcdn.com/cubed3/wCTntgEXVYYYnx4l/favicon.svg?fit=max\u0026auto=format\u0026n=wCTntgEXVYYYnx4l\u0026q=85\u0026s=3b0cb7aa770d2abd546ef19463fbba8c","navbar":{"links":[{"href":"https://cube.dev/demos","label":"Demos"},{"href":"https://cube.dev/changelog","label":"Changelog"},{"href":"https://slack.cube.dev","label":"Community"}],"primary":{"type":"button","label":"Get Started","href":"https://cubecloud.dev/auth/signup"}},"footer":{"socials":{"x":"https://x.com/the_cube_dev","github":"https://github.com/cube-js/cube","linkedin":"https://www.linkedin.com/company/cube-dev"},"links":[{"header":"Legal","items":[{"label":"Privacy Policy","href":"https://cube.dev/legal/privacy-policy"},{"label":"Cookie Preferences","href":"#cookie-preferences"}]}]},"seo":{"metatags":{"og:type":"website","og:site_name":"Cube Documentation"},"indexing":"navigable"},"icons":{"library":"tabler"},"styling":{"codeblocks":"dark","latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"cubed3","hasAudioNarration":false,"actualSubdomain":"cubed3","customDomains":["docs.cube.dev"],"gitSource":{"type":"github","owner":"cube-js","repo":"cube","deployBranch":"master","contentDirectory":"docs-mintlify","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6afec725a79a2a42f4990279","clientVersion":"0.0.4205","searchFilterCounts":[{"language":"default","tag":"API","count":238},{"language":"default","tag":"Platform Endpoints","count":231},{"language":"default","tag":"Documentation","count":101},{"language":"default","tag":"Admin","count":95},{"language":"default","tag":"Data Modeling","count":65},{"language":"default","tag":"Recipes","count":47},{"language":"default","tag":"Topics","count":47},{"language":"default","tag":"Reference","count":44},{"language":"default","tag":"Connect to data","count":31},{"language":"default","tag":"Explore \u0026 Analyze","count":30}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#content-area table,.mdx-content table{width:100%!important}.cube-consent{position:fixed;right:16px;bottom:16px;z-index:2147483000;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;width:min(440px, calc(100vw - 32px));padding:16px;background:#fff;color:#111827;border:1px solid #e5e7eb;border-radius:8px;box-shadow:0 8px 24px rgb(0 0 0 / 12%);font-size:14px;line-height:1.5}html.dark .cube-consent{background:#111318;color:#f3f4f6;border-color:#2b2f38}.cube-consent__title{margin:0;padding-right:24px;font-size:16px;font-weight:600}.cube-consent__text,.cube-consent__status{margin:0;color:#4b5563}html.dark .cube-consent__text,html.dark .cube-consent__status{color:#b6bcc8}.cube-consent__link{color:inherit;text-decoration:underline}.cube-consent__actions{display:flex;gap:8px}.cube-consent__button{flex:1;padding:8px 16px;border:1px solid #111827;border-radius:6px;background:#111827;color:#fff;font:inherit;font-weight:500;cursor:pointer}html.dark .cube-consent__button{border-color:#f3f4f6;background:#f3f4f6;color:#111318}.cube-consent__button:hover{opacity:0.88}.cube-consent__button:focus-visible,.cube-consent__close:focus-visible,.cube-consent__link:focus-visible{outline:2px solid #111827;outline-offset:2px}html.dark .cube-consent :focus-visible{outline-color:#f3f4f6}.cube-consent__close{position:absolute;top:8px;right:8px;width:24px;height:24px;padding:0;border:0;background:transparent;color:inherit;font-size:20px;line-height:1;cursor:pointer}"}],"page":{"pagePath":"embedding/authentication/jwt","slug":"/embedding/authentication/jwt","pageMetadata":{"title":"JSON Web Token authentication","description":"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.","href":"/embedding/authentication/jwt"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Info,OptimizedImage,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Info)_missingMdxReference(`Info`,true);if(!OptimizedImage)_missingMdxReference(`OptimizedImage`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Some visualization tools (e.g., custom front-end applications) can pass access tokens based\non the `,_jsx(_components.a,{href:`https://en.wikipedia.org/wiki/JSON_Web_Token`,children:`JSON Web Token`}),` (JWT) standard to Cube. These tokens can be either generated\nby these applications or obtained from an identity provider. Cube then validates these tokens.`]}),`\n`,_jsx(_components.p,{children:`The diagram below shows how it works during the request processing in Cube:`}),`\n`,_jsx(`div`,{style:{textAlign:`center`},children:_jsx(OptimizedImage,{src:`https://ucarecdn.com/98431f1f-4693-4218-adcc-34e8635eb2dd/`,style:{border:`none`},width:`80%`})}),`\n`,_jsx(Heading,{level:`2`,id:`configuration`,children:`Configuration`}),`\n`,_jsxs(_components.p,{children:[`Relevant configuration options: `,_jsx(_components.a,{href:`/reference/configuration/config#check_auth`,children:_jsx(_components.code,{children:`check_auth`})}),` and `,_jsx(_components.a,{href:`/reference/configuration/config#jwt`,children:_jsx(_components.code,{children:`jwt`})}),`.`]}),`\n`,_jsxs(_components.p,{children:[`Relevant environment variables: `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_api_secret`,children:_jsx(_components.code,{children:`CUBEJS_API_SECRET`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_api_secrets`,children:_jsx(_components.code,{children:`CUBEJS_API_SECRETS`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_key`,children:_jsx(_components.code,{children:`CUBEJS_JWT_KEY`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwk_url`,children:_jsx(_components.code,{children:`CUBEJS_JWK_URL`})}),`,\n`,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_audience`,children:_jsx(_components.code,{children:`CUBEJS_JWT_AUDIENCE`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_issuer`,children:_jsx(_components.code,{children:`CUBEJS_JWT_ISSUER`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_subject`,children:_jsx(_components.code,{children:`CUBEJS_JWT_SUBJECT`})}),`, `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_claims_namespace`,children:_jsx(_components.code,{children:`CUBEJS_JWT_CLAIMS_NAMESPACE`})}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`custom-authentication`,children:`Custom authentication`}),`\n`,_jsxs(_components.p,{children:[`Cube allows you to provide your own JWT verification logic. You can use the\n`,_jsx(_components.a,{href:`/reference/configuration/config#check_auth`,children:_jsx(_components.code,{children:`check_auth`})}),` configuration option to verify a JWT and set the security context.`]}),`\n`,_jsx(_components.p,{children:`A typical use case would be:`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsx(_components.li,{children:`A web server serves a page which needs to communicate with the Cube API.`}),`\n`,_jsx(_components.li,{children:`The web server generates a JWT. The\nserver includes the token in the page or provides the token to\nthe frontend via an XHR request. The token is then stored in the local storage or\na cookie.`}),`\n`,_jsx(_components.li,{children:`The token is used for calls to the Cube API.`}),`\n`,_jsx(_components.li,{children:`The token is received by Cube, and verified using any available JWKS (if configured)`}),`\n`,_jsxs(_components.li,{children:[`Once decoded, the token claims are injected into the `,_jsx(_components.a,{href:`/docs/data-modeling/access-control/context`,children:`security\ncontext`}),`.`]}),`\n`]}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[_jsx(_components.strong,{children:`In development mode, the token is not required for authorization.`}),` JWT\nverification on this API is on unless Cube is in\n`,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_dev_mode`,children:`development mode`}),`,\nwhich is enabled by `,_jsx(_components.code,{children:`CUBEJS_DEV_MODE=true`}),` — or, when you embed\n`,_jsx(_components.code,{children:`@cubejs-backend/server-core`}),` directly, by the `,_jsx(_components.code,{children:`devServer`}),` option. `,_jsx(_components.code,{children:`NODE_ENV`}),` has no\neffect on it. A custom `,_jsx(_components.a,{href:`/reference/configuration/config#check_auth`,children:_jsx(_components.code,{children:`check_auth`})}),` that\nrejects unauthenticated requests enforces verification either way.`]}),_jsxs(_components.p,{children:[`Verification is therefore on by default everywhere, including under `,_jsx(_components.code,{children:`cubejs server`}),`,\nthe official Docker images and a bare embedded server. Development mode also\nexposes Playground’s unauthenticated endpoints, which hand out and mint valid tokens\ncarrying any security context, signed with your API secret. This is\nintentional — development mode is designed for local development machines only. Never\nuse it in production, and using it in the Cube cloud platform is highly discouraged\nbecause it bypasses the platform’s security model.`]}),_jsxs(_components.p,{children:[`You can still pass a token in development mode to `,_jsx(_components.a,{href:`/docs/data-modeling/access-control/context`,children:`set a security\ncontext`}),`.`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`generating-json-web-tokens`,children:`Generating JSON Web Tokens`}),`\n`,_jsxs(_components.p,{children:[`Authentication tokens are generated based on your API secret. Cube CLI generates\nan API Secret when a project is scaffolded and saves this value in the `,_jsx(_components.code,{children:`.env`}),`\nfile as `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_api_secret`,children:_jsx(_components.code,{children:`CUBEJS_API_SECRET`})}),`.`]}),`\n`,_jsx(_components.p,{children:`You can generate two types of tokens:`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:`Without security context, which will mean that all users will have the same\ndata access permissions.`}),`\n`,_jsx(_components.li,{children:`With security context, which will allow you to implement role-based security\nmodels where users will have different levels of access to data.`}),`\n`]}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[`It is considered best practice to use an `,_jsx(_components.code,{children:`exp`}),` expiration claim to limit the\nlifetime of your public tokens. `,_jsx(_components.a,{href:`https://github.com/auth0/node-jsonwebtoken#token-expiration-exp-claim`,children:`Learn more in the JWT docs`}),`.`]})}),`\n`,_jsxs(_components.p,{children:[`You can find a library to generate JWTs for your programming language\n`,_jsx(_components.a,{href:`https://jwt.io/#libraries-io`,children:`here`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`In Node.js, the following code shows how to generate a token which will expire\nin 30 days. We recommend using the `,_jsx(_components.code,{children:`jsonwebtoken`}),` package for this.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` jwt`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`require`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"jsonwebtoken\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` CUBE_API_SECRET`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"secret\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` cubeToken`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`jwt`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`sign`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`({}, `}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:`CUBE_API_SECRET`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, { `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`expiresIn:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"30d\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` })`})]}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Then, in a web server or cloud function, create a route which generates and\nreturns a token. In general, you will want to protect the URL that generates\nyour token using your own user authentication and authorization:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`17`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`17`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`use`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`((`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`next`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` (!`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`redirect`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"/login\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:` next`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`app`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"/auth/cubejs-token\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, (`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6A9955`,\"--shiki-dark\":`#6A9955`},children:` // Take note: Cube expects the JWT payload to contain an object!`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` token:`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwt`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`sign`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`req`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`user`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`process`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:`CUBEJS_API_SECRET`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`, {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` expiresIn:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"1d\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` })`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`})`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Then, on the client side, (assuming the user is signed in), fetch a token from\nthe web server:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`16`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`let`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` apiTokenPromise`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:` cubeApi`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`cube`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` () `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` (!`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`apiTokenPromise`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` apiTokenPromise`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = `}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:`API_URL`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"/auth/cubejs-token`\"}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`((`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` res`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`json`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`())`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#DCDCAA`,\"--shiki-dark\":`#DCDCAA`},children:`then`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`((`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`r`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`=>`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` r`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`token`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` `})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#C586C0`,\"--shiki-dark\":`#C586C0`},children:` return`}),_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` apiTokenPromise`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` apiUrl:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\" `\"}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#4FC1FF`,\"--shiki-dark\":`#4FC1FF`},children:`API_URL`}),_jsx(_components.span,{style:{color:`#569CD6`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:\"/cubejs-api/v1`\"})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`You can optionally store this token in local storage or in a cookie, so that you\ncan then use it to query the Cube API.`}),`\n`,_jsx(Heading,{level:`2`,id:`using-json-web-key-sets`,children:`Using JSON Web Key Sets`}),`\n`,_jsx(Info,{children:_jsxs(_components.p,{children:[`Looking for a guide on how to connect a specific identity provider? Check out\nour recipes for using `,_jsx(_components.a,{href:`/embedding/authentication/auth0`,children:`Auth0`}),` or `,_jsx(_components.a,{href:`/embedding/authentication/aws-cognito`,children:`AWS\nCognito`}),` with Cube.`]})}),`\n`,_jsxs(_components.p,{children:[`As mentioned previously, Cube supports verifying JWTs using industry-standard\nJWKS. The JWKS can be provided either from a URL, or as a JSON object conforming\nto `,_jsx(_components.a,{href:`https://tools.ietf.org/html/rfc7517#section-4`,children:`JWK specification RFC 7517 Section 4`}),`, encoded as a string.`]}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[`Once a key is configured with `,_jsx(_components.code,{children:`jwt.key`}),`, `,_jsx(_components.code,{children:`jwt.jwkUrl`}),`,\n`,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwt_key`,children:_jsx(_components.code,{children:`CUBEJS_JWT_KEY`})}),`, or\n`,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_jwk_url`,children:_jsx(_components.code,{children:`CUBEJS_JWK_URL`})}),`,\nCube verifies tokens only against that key. Tokens signed with\n`,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_api_secret`,children:_jsx(_components.code,{children:`CUBEJS_API_SECRET`})}),`\nor `,_jsx(_components.a,{href:`/reference/configuration/environment-variables#cubejs_api_secrets`,children:_jsx(_components.code,{children:`CUBEJS_API_SECRETS`})}),`\nare rejected with `,_jsx(_components.code,{children:`403 Invalid token`}),`; there is no fallback to the API secret.\nWhen using a JWKS URL, each token must also carry a `,_jsx(_components.code,{children:`kid`}),` header that matches a\nkey in the set.`]}),_jsxs(_components.p,{children:[`To accept both kinds of tokens, write a custom `,_jsx(_components.a,{href:`/reference/configuration/config#check_auth`,children:_jsx(_components.code,{children:`check_auth`})}),`\nthat verifies each token against the right key.`]}),_jsxs(_components.p,{children:[`In the Cube cloud platform, `,_jsx(_components.a,{href:`/reference/core-data-apis#personal-core-data-api-token`,children:`personal Core Data API tokens`}),`\nkeep working with JWKS configured: they are validated by the platform before\nJWT verification runs.`]})]}),`\n`,_jsx(Heading,{level:`3`,id:`using-a-key-as-a-json-string`,children:`Using a key as a JSON string`}),`\n`,_jsxs(_components.p,{children:[`Add the following to your `,_jsx(_components.code,{children:`cube.js`}),` configuration file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`module`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`exports`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` key:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cJWK_AS_STRING>\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Or configure the same using environment variables:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`dotenv`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`dotenv`,children:_jsxs(_components.code,{language:`dotenv`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`CUBEJS_JWT_KEY`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'\u003cJWK_AS_STRING>'`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`using-a-key-from-a-url`,children:`Using a key from a URL`}),`\n`,_jsx(Info,{children:_jsx(_components.p,{children:`When using a URL to fetch the JWKS, Cube will automatically cache the response,\nre-use it and update if a key rotation has occurred.`})}),`\n`,_jsxs(_components.p,{children:[`Add the following to your `,_jsx(_components.code,{children:`cube.js`}),` configuration file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`module`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`exports`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwkUrl:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cURL_TO_JWKS_JSON>\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Or configure the same using environment variables:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`dotenv`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`dotenv`,children:_jsxs(_components.code,{language:`dotenv`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`CUBEJS_JWK_URL`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'\u003cURL_TO_JWKS_JSON>'`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`verifying-claims`,children:`Verifying claims`}),`\n`,_jsxs(_components.p,{children:[`Cube can also verify the audience, subject and issuer claims in JWTs. Similarly\nto JWK configuration, these can also be configured in the `,_jsx(_components.code,{children:`cube.js`}),`\nconfiguration file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`module`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`exports`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` audience:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cAUDIENCE_FROM_IDENTITY_PROVIDER>\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` issuer:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cISSUER_FROM_IDENTITY_PROVIDER>\"`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` subject:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"\u003cSUBJECT_FROM_IDENTITY_PROVIDER>\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Using environment variables:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`dotenv`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`dotenv`,children:_jsxs(_components.code,{language:`dotenv`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`CUBEJS_JWT_AUDIENCE`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'\u003cAUDIENCE_FROM_IDENTITY_PROVIDER>'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`CUBEJS_JWT_ISSUER`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'\u003cISSUER_FROM_IDENTITY_PROVIDER>'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:`CUBEJS_JWT_SUBJECT`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:`'\u003cSUBJECT_FROM_IDENTITY_PROVIDER>'`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`3`,id:`custom-claims-namespace`,children:`Custom claims namespace`}),`\n`,_jsxs(_components.p,{children:[`Cube can also extract claims defined in custom namespaces. Simply specify the\nnamespace in your `,_jsx(_components.code,{children:`cube.js`}),` configuration file:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`5`,language:`javascript`,children:_jsx(_components.pre,{className:`shiki shiki-themes dark-plus dark-plus`,style:{backgroundColor:`#0B0C0E`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},language:`javascript`,children:_jsxs(_components.code,{language:`javascript`,numberOfLines:`5`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`module`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#4EC9B0`,\"--shiki-dark\":`#4EC9B0`},children:`exports`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` = {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` jwt:`}),_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#9CDCFE`,\"--shiki-dark\":`#9CDCFE`},children:` claimsNamespace:`}),_jsx(_components.span,{style:{color:`#CE9178`,\"--shiki-dark\":`#CE9178`},children:` \"my-custom-namespace\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#D4D4D4`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"dark","config":{},"pageMetadata":{"title":"JSON Web Token authentication","description":"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.","href":"/embedding/authentication/jwt"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Configuration","slug":"configuration","depth":2,"children":[]},{"title":"Custom authentication","slug":"custom-authentication","depth":2,"children":[]},{"title":"Generating JSON Web Tokens","slug":"generating-json-web-tokens","depth":2,"children":[]},{"title":"Using JSON Web Key Sets","slug":"using-json-web-key-sets","depth":2,"children":[{"title":"Using a key as a JSON string","slug":"using-a-key-as-a-json-string","depth":3,"children":[]},{"title":"Using a key from a URL","slug":"using-a-key-from-a-url","depth":3,"children":[]},{"title":"Verifying claims","slug":"verifying-claims","depth":3,"children":[]},{"title":"Custom claims namespace","slug":"custom-claims-namespace","depth":3,"children":[]}]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/cubed3/73c42f6b43b9b3b0/scripts/extract-chat.js","/_mintlify/custom/cubed3/08d502537a7bd0d7/scripts/extract-core-data.js","/_mintlify/custom/cubed3/476a9fa93e98d93b/consent.js"],"subdomain":"cubed3","siteName":"Cube Documentation","title":"JSON Web Token authentication - Cube Documentation","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-29T21:27:17.646Z","originalFileLocation":"embedding/authentication/jwt.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Cube Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"JSON Web Token authentication - Cube Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Cube Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.cube.dev/embedding/authentication/jwt\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://cubed3.mintlify.site/_mintlify/api/og/v2?division=Authentication\u0026amp;title=JSON+Web+Token+authentication\u0026amp;description=Walks+through+validating+JWTs+from+clients+or+identity+providers%2C+the+relevant+Cube+settings+and+environment+variables%2C+and+custom+check_auth+implementations.\u0026amp;theme=6d1e003873cec4de62649d7c\u0026amp;signature=61a5384ebe8c4cc1ee3a719f143ee6c2adca7453e89747c96aee6ac9350c87e2\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"JSON Web Token authentication - Cube Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://cubed3.mintlify.site/_mintlify/api/og/v2?division=Authentication\u0026amp;title=JSON+Web+Token+authentication\u0026amp;description=Walks+through+validating+JWTs+from+clients+or+identity+providers%2C+the+relevant+Cube+settings+and+environment+variables%2C+and+custom+check_auth+implementations.\u0026amp;theme=6d1e003873cec4de62649d7c\u0026amp;signature=61a5384ebe8c4cc1ee3a719f143ee6c2adca7453e89747c96aee6ac9350c87e2\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/cubed3/JtLYPWhDFrYGSK8W/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Cube Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#5339CF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.cube.dev/embedding/authentication/jwt\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/embedding/authentication/jwt.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.cube.dev/#organization\",\"name\":\"Cube Documentation\",\"url\":\"https://docs.cube.dev\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/cubed3/wCTntgEXVYYYnx4l/logo/light.svg?fit=max\u0026auto=format\u0026n=wCTntgEXVYYYnx4l\u0026q=85\u0026s=8bbf45ba64eac6116629064fac55aad7\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.cube.dev#website\",\"name\":\"Cube Documentation\",\"url\":\"https://docs.cube.dev\",\"publisher\":{\"@id\":\"https://docs.cube.dev/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.cube.dev/embedding/authentication/jwt#webpage\",\"url\":\"https://docs.cube.dev/embedding/authentication/jwt\",\"name\":\"JSON Web Token authentication\",\"description\":\"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\",\"dateModified\":\"2026-10-29T21:27:17.646Z\",\"isPartOf\":{\"@id\":\"https://docs.cube.dev#website\"},\"breadcrumb\":{\"@id\":\"https://docs.cube.dev/embedding/authentication/jwt#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.cube.dev/embedding/authentication/jwt#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Cube Documentation\",\"item\":\"https://docs.cube.dev\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JSON Web Token authentication\",\"item\":\"https://docs.cube.dev/embedding/authentication/jwt\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.cube.dev/embedding/authentication/jwt#article\",\"headline\":\"JSON Web Token authentication\",\"name\":\"JSON Web Token authentication\",\"description\":\"Walks through validating JWTs from clients or identity providers, the relevant Cube settings and environment variables, and custom check_auth implementations.\",\"url\":\"https://docs.cube.dev/embedding/authentication/jwt\",\"mainEntityOfPage\":{\"@id\":\"https://docs.cube.dev/embedding/authentication/jwt#webpage\"},\"dateModified\":\"2026-10-29T21:27:17.646Z\",\"publisher\":{\"@id\":\"https://docs.cube.dev/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.cube.dev#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Cube Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Cube Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/embedding/authentication/jwt.md","siteName":"Cube Documentation","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/docs/introduction"}]},{"tab":"Admin","pages":[{"title":"Admin","href":"/admin/connect-to-data"}]},{"tab":"Embedding","groups":[{"group":"Embedding","pages":[{"title":"Overview","href":"/embedding"},{"title":"React Embed SDK","href":"/embedding/react-embed-sdk"}]},{"group":"Iframe embedding","pages":[{"title":"Dashboards","href":"/embedding/iframe/dashboards"},{"title":"Analytics Chat","href":"/embedding/iframe/analytics-chat"},{"title":"Creator Mode","href":"/embedding/iframe/creator-mode"},{"title":"Show and hide features","href":"/embedding/iframe/feature-visibility"},{"title":"Customization","href":"/embedding/iframe/customization"},{"title":"Localization","href":"/embedding/iframe/localization"},{"title":"Time zones","href":"/embedding/iframe/time-zones"},{"title":"Events \u0026 actions","href":"/embedding/iframe/events"},{"group":"Authentication","pages":[{"title":"Private embedding","href":"/embedding/iframe/auth/private"},{"title":"Signed embedding","description":"Authenticate iframe-embedded Cube content with secure, server-generated sessions.","href":"/embedding/iframe/auth/signed"}]}]},{"group":"Using Core Data APIs","pages":[{"group":"Authentication","pages":[{"title":"JSON Web Token authentication","href":"/embedding/authentication/jwt"},{"title":"Security context","description":"Explains how verified JWT claims become the security context Cube uses for access control, query rewrite, and multi-tenant configuration.","href":"/embedding/authentication/security-context"},{"title":"Authenticate requests to Cube with Auth0","sidebarTitle":"Auth0","href":"/embedding/authentication/auth0"},{"title":"Authenticate requests to Cube with AWS Cognito","sidebarTitle":"AWS Cognito","href":"/embedding/authentication/aws-cognito"}]},{"title":"Multitenancy","href":"/embedding/multitenancy"}]}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/data-modeling/cube"}]},{"tab":"Cube Core","pages":[{"title":"Cube Core","href":"/cube-core"}]},{"tab":"Recipes","pages":[{"title":"Recipes","href":"/recipes"}]},{"tab":"API","pages":[{"title":"API","href":"/api-reference/introduction"}]}]},"basePath":"","title":"JSON Web Token authentication - Cube Documentation","deploymentId":"dpl_FZMKUpaaKiVETbfqhoUe4sPFDTmY","buildId":"dpl_FZMKUpaaKiVETbfqhoUe4sPFDTmY","dynamics":["a74be98ba7"],"chunks":["zoom-image-lightbox-B9O1U98p.js","lightbox-handle-r17bVUz3.js"]}