Enable Superset Dashaboard Embedded and hide Edit Chart and More Option #42758
Replies: 2 comments
|
Hi @Manglam44! I'm Dosu and I'm helping the Apache Superset team. Here's a consolidated step-by-step reference for embedding a Superset dashboard with the guest token flow: 1. FEATURE_FLAGS = {
"EMBEDDED_SUPERSET": True,
}
# Guest token config — change the secret in production!
GUEST_TOKEN_JWT_SECRET = "your-strong-secret-here" # generate with: openssl rand -base64 42
GUEST_TOKEN_JWT_EXP_SECONDS = 300 # 5 min, SDK auto-refreshes
GUEST_ROLE_NAME = "Public" # FAB role assigned to every guest user
# CSP — allow your app domain to iframe Superset
TALISMAN_ENABLED = True
TALISMAN_CONFIG = {
"content_security_policy": {
"default-src": ["'self'"],
"frame-ancestors": ["'self'", "https://your-app-domain.com"],
"img-src": ["'self'", "blob:", "data:"],
"worker-src": ["'self'", "blob:"],
"connect-src": ["'self'"],
"object-src": "'none'",
"style-src": ["'self'", "'unsafe-inline'"],
"script-src": ["'self'", "'strict-dynamic'"],
},
"content_security_policy_nonce_in": ["script-src"],
"force_https": False, # False if TLS is terminated by a reverse proxy
"session_cookie_secure": True,
}
# Cross-origin cookie settings for embedding
SESSION_COOKIE_SAMESITE = "None"
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
# If behind a reverse proxy
ENABLE_PROXY_FIX = True2. Enable embedding on the dashboard In the Superset UI: open the dashboard → "…" menu → Embed Dashboard → add your allowed domains. This creates an 3. Guest token payload structure Your backend calls {
"user": { "username": "guest_user", "first_name": "Guest", "last_name": "User" },
"resources": [{ "type": "dashboard", "id": "<embedded-dashboard-uuid>" }],
"rls": []
}The 4. Frontend SDK usage npm install @superset-ui/embedded-sdkimport { embedDashboard } from "@superset-ui/embedded-sdk";
embedDashboard({
id: "embedded-dashboard-uuid", // from the Embed Dashboard dialog
supersetDomain: "https://superset.example.com",
mountPoint: document.getElementById("dashboard-container"),
fetchGuestToken: () =>
fetch("/your-backend/guest-token")
.then(r => r.json())
.then(d => d.token),
dashboardUiConfig: {
hideTitle: true,
hideChartControls: true, // hides the "..." menu and edit controls on charts
hideTab: false,
},
});The 5. Common causes of "Access denied" / blank iframe
Feel free to share your specific error logs and config — happy to help narrow down the exact issue you're hitting. To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
@Manglam44 — here's a consolidated reference for the full embedding flow: 1. FEATURE_FLAGS = {
"EMBEDDED_SUPERSET": True,
}
# Guest token — change the secret in production
GUEST_TOKEN_JWT_SECRET = "your-strong-secret-here"
GUEST_TOKEN_JWT_EXP_SECONDS = 300 # SDK auto-refreshes before expiry
GUEST_ROLE_NAME = "Public"
# CSP — allow your app to iframe Superset
TALISMAN_ENABLED = True
TALISMAN_CONFIG = {
"content_security_policy": {
"default-src": ["'self'"],
"frame-ancestors": ["'self'", "https://your-app-domain.com"],
"img-src": ["'self'", "blob:", "data:"],
"worker-src": ["'self'", "blob:"],
"connect-src": ["'self'"],
"object-src": "'none'",
"style-src": ["'self'", "'unsafe-inline'"],
"script-src": ["'self'", "'strict-dynamic'"],
},
"content_security_policy_nonce_in": ["script-src"],
"force_https": False, # False when TLS is terminated at a reverse proxy
"session_cookie_secure": True,
}
# Cross-origin cookie settings (required for iframe embedding)
SESSION_COOKIE_SAMESITE = "None"
SESSION_COOKIE_SECURE = True
# If behind a reverse proxy
ENABLE_PROXY_FIX = True2. Enable embedding on the dashboard Dashboard → "…" menu → Embed Dashboard → add your allowed domains (comma-separated). An empty list means any origin can embed [3]. 3. Guest token request payload Your backend (not the browser) calls {
"user": { "username": "guest_user", "first_name": "Guest", "last_name": "User" },
"resources": [{ "type": "dashboard", "id": "<embedded-dashboard-uuid>" }],
"rls": []
}Use the embedded UUID (from the Embed Dashboard dialog), not the dashboard's integer ID. 4. Frontend SDK usage npm install @superset-ui/embedded-sdkimport { embedDashboard } from "@superset-ui/embedded-sdk";
embedDashboard({
id: "embedded-dashboard-uuid",
supersetDomain: "https://superset.example.com",
mountPoint: document.getElementById("dashboard-container"),
fetchGuestToken: () =>
fetch("/your-backend/guest-token")
.then(r => r.json())
.then(d => d.token),
dashboardUiConfig: {
hideTitle: true,
hideChartControls: true, // hides "Edit chart" and the "..." menu on charts
hideTab: false,
},
});
5. Common causes of "Access denied" / blank iframe
Feel free to share your specific error logs and config — happy to help narrow down the exact issue you're hitting. To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
Uh oh!
There was an error while loading. Please reload this page.
Bug description
Summary
We're trying to embed a Superset dashboard into our own web application using the
Embedded SDK + guest token flow, but have run into multiple errors along the way and
would appreciate a working step-by-step reference from the community, since the
existing docs leave gaps for our setup.
What we're trying to achieve
Steps we've followed so far
EMBEDDED_SUPERSETfeature flag insuperset_config.py/api/v1/security/loginthen/api/v1/security/guest_token/@superset-ui/embedded-sdkon the frontend and calledembedDashboard(...)with
fetchGuestTokenpointing at our backend endpointErrors encountered
?standalone=2directly>What we've already tried
EMBEDDED_SUPERSETflag is set and Superset restartedall_datasource_accessand dashboard-level role accessresourcesscope)standalone=2in the URLQuestion
Could someone share a confirmed-working, current step-by-step flow (or point to an
up-to-date example repo) for:
superset_config.pysettings required for embedding (feature flag, CORS,GUEST_TOKEN settings, TALISMAN/CSP if relevant)
correctly configured
Happy to share our full config and error logs in the thread. Thanks in advance —
this seems like a common ask so a clear answer here would likely help others too.
Screenshots/recordings
No response
Superset version
master / latest-dev
Python version
3.11
Node version
16
Browser
Chrome
Additional context
No response
Checklist
All reactions