Skip to main content

Security and CSP

Content Security Policy​

The bundle runs with zero violations under a strict policy. There is no eval and no new Function. Two things need attention.

Directives​

DirectiveNeeds
script-srcYour deployment origin, so the module can load.
connect-srcYour deployment origin, for the API calls the elements make.
style-srcA nonce, because the elements inject their styles at runtime.
font-srcThe origin serving the custom font, if a variant or init() sets one.

The style nonce​

Give the embed your nonce one of two ways.

Pass it to init():

init({
// ...
styleNonce: "r4nd0m-per-request-value",
});

Or put it in the host page's head, where the embed picks it up:

<meta property="csp-nonce" content="r4nd0m-per-request-value" />

Use 'unsafe-inline' instead and the elements will render, but you have weakened the policy for your whole page to avoid one configuration line. It is not recommended.

CORS​

The bundle is served with Access-Control-Allow-Origin: *, so no origin configuration is needed to load it. Hashed chunks are immutable and the entry point is no-cache, so a deployment upgrade is picked up on the next page load rather than being pinned by a cache.

The API calls the elements make are covered by the deployment's API CORS policy, which applies to every tenant. In an on-premises deployment it is server.cors.allowedorigins in the configuration, and defaults to *. If your operator has narrowed it, add the origin of every page that hosts an element, or the browser blocks the elements' requests. A tenant administrator cannot change this setting.

What the embed does not do​

  • It never runs an OAuth flow, opens a popup, or mounts a renewal iframe.
  • It never reads or writes localStorage, sessionStorage, or cookies on your page.
  • It never persists the token you hand it beyond the life of the page.

Your application is the only thing that holds a session. See Authentication and tokens.

Hiding is not authorization​

This is the one thing worth being blunt about.

Turning a section off in a variant, or passing sections to init(), removes the UI and stops the requests behind it. It does not change what the token can do. A person with a token carrying view_sessions can read their sessions whether or not the card is visible.

Scopes are the boundary. Grant the client only the scopes the elements it places actually need, which is what the Embed tab derives for you, and treat section visibility as a presentation choice.

The same applies to the composite's tabs. Hiding one makes its route unreachable inside the element, not its data unreachable through the API.

Binding a variant to a client on its Embed tab is not a boundary either. It records what the application embeds so the console can generate its code and scope list, but nothing checks it at runtime.

Multi-tenant hosts​

init() names one tenant and one workspace, and replaces the whole configuration when called again. In a product that serves several customers from one page, call init() on each switch rather than mounting two elements against two tenants: there is one configuration and one tokenProvider per page.

See also​