Secure your embed integration
Use your host login session to establish identity, an origin allowlist to restrict browser access, and server-side checks to protect tools. This page configures those boundaries. See Test your integration for scenarios and the go-live checklist for release verification.
Preparation and responsibilities
You need Dashboard access to manage the service agent, a host backend, and permission to change website response headers. Configure the embed settings and token issuance before reviewing these responsibilities.
| Platform boundary | Host responsibility |
|---|---|
| Embedded users access only their own sessions under the bound agent | Derive customer_id from a verified login session, not a browser-supplied identity |
| Cross-user and cross-agent resource access returns 404 | Keep API Keys server-side; authenticate issuance requests and protect against cross-site request forgery |
| Browser origin checks and iframe restrictions | Register actual website origins and restrict scripts loaded by the host page |
Protect identity and credentials
Your backend uses the organization API key to call POST /customer/v1/grant_codes and issue a one-time grant code. Send only the code to the browser, where the page session exchanges it for a customer access token. Revalidate the host login session for every grant code. Never let a request body’s customer_id establish identity. Keep API Keys, grant codes, and access tokens out of URLs, HTML, and logs.
Kit’s transport holds its token in page memory only. A publishableKey is public and ships in the page source; an anonymous visitor is a new visitor after a reload. Anonymous identity is not a logged-in account on your website.
On logout, stop issuance, remove the chat component, and revoke the relevant credentials from your backend. Clearing the page is not revocation. Blocking a customer prevents new sign-ins organization-wide and revokes that customer’s existing tokens. Kit and Hosted both renew before expiry. See Customer sign-in.
The model may repeat instructions, system_message, page context, or tool results. Include only information the current user may access. Never pass secrets or another user’s data as context.
Restrict page origins
The origin allowlist can currently only be configured in the Dashboard. Open 服务智能体 → your agent → 接入 → 接入方式与外观 → 嵌入设置 (Service agents → your agent → Integrate → Integration methods & appearance → Embed settings). Click 添加 (Add), enter an origin such as https://shop.example.com, then 保存嵌入设置 (Save embed settings). Expected: the saved message confirms no new agent version was created.
allowed_origins permits at most 50 entries. Enter origins without paths, queries, or fragments. Regular origins require HTTPS. https://*.example.com matches one subdomain level, not the root or deeper subdomains, and does not support ports. 允许 localhost(本地开发) is for local HTTP development and defaults to off.
During issuance, use origin to bind the sign-in to one allowed origin from the embed settings; it must match an entry exactly. Changing embed settings does not revoke issued tokens. Revoke credentials when access must be withdrawn immediately.
A disallowed origin returns HTTP 403 with EMBED_ORIGIN_NOT_ALLOWED. Correct the configuration before reconnecting. Origin checks constrain browsers; non-browser requests without Origin bypass this check. It does not replace token authentication.
Protect tool access
Your MCP server must authenticate the platform caller before treating X-Praxis-External-User-Id as the end-user identity. The platform also sends X-Praxis-Agent-Id and X-Praxis-Session-Id. Sessions without an end user do not carry these identity headers.
Reject requests missing required identity. Scope every query to that user, and verify ownership and business state before changing an order. Do not trust a model-supplied user ID or a public request merely because it contains identity headers. Authenticate the caller using MCP-configured headers before trusting platform-supplied identity.
Confirmation cards check intent; clicking allow does not grant data access. Client tools and page context come from the browser and cannot enforce authorization.
Protect the host page
This response-header example assumes initialization scripts live in same-origin JavaScript files and Kit loads from its CDN. Narrow image and other sources to your site’s needs. If initialization remains inline, add a CSP nonce or hash for that script.
Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.deepraxis.com; style-src 'self' 'unsafe-inline' https://cdn.deepraxis.com; connect-src 'self' https://api.deepraxis.com https://cdn.deepraxis.com; frame-src https://agent.praxisusercontent.com; font-src 'self' https://cdn.deepraxis.com data:; img-src 'self' https: data: blob:; frame-ancestors 'none'; base-uri 'self';Kit themes use inline styles, which this policy allows. Connection sources must match api.url. frame-src permits loading the hosted iframe; frame-ancestors 'none' prevents other sites from embedding your host page.
Platform iframe ancestors come from the allowlist; an empty list prevents framing. Hosted cannot be framed. Kit’s open Shadow DOM isolates styles, but scripts on the same page can read it. Avoid sharing the chat page with untrusted scripts.
For CDN integrity checks, copy the actual fixed-version URL and integrity generated by the Dashboard, retaining crossorigin="anonymous". Do not attach a fixed hash to the floating /v1/ URL or use an illustrative hash as a release value.
Verify and continue
Reload from an allowed website and send a message. Inspect the host response’s CSP in browser Network tools. Console should show no CSP failures loading Kit or connecting to the API. Confirm the issuance route returns only short-lived credentials and that tool access is scoped to the logged-in user.
Test your integration · Go-live checklist · Embed limits and errors.