How can I implenet login via URL param on Superset? #30175
Replies: 2 comments 2 replies
-
Hey @biratdatta! I'm a bot here to help you out with any bugs, questions, or contributions. Let's tackle those issues together! To implement login via URL parameters on Superset and embed Superset in an iframe to avoid cross-site issues, you can use the Superset Embedded SDK. Here’s how you can achieve both: Embedding a Dashboard with URL ParametersFirst, install the Superset Embedded SDK: npm install --save @superset-ui/embedded-sdk Then, use the SDK to embed a dashboard and pass URL parameters for login: import { embedDashboard } from "@superset-ui/embedded-sdk";
embedDashboard({
id: "abc123", // given by the Superset embedding UI
supersetDomain: "https://superset.example.com",
mountPoint: document.getElementById("my-superset-container"), // any html element that can contain an iframe
fetchGuestToken: () => fetchGuestTokenFromBackend(),
dashboardUiConfig: {
hideTitle: true,
filters: {
expanded: true,
},
urlParams: {
foo: 'value1',
bar: 'value2',
// Add your login parameters here
}
},
iframeSandboxExtras: ['allow-top-navigation', 'allow-popups-to-escape-sandbox']
}); Authentication with Guest TokensTo handle authentication, you need to create a guest token from your backend and pass it to the frontend. Here’s an example of how to create a guest token: {
"user": {
"username": "stan_lee",
"first_name": "Stan",
"last_name": "Lee"
},
"resources": [{
"type": "dashboard",
"id": "abc123"
}],
"rls": [
{ "clause": "publisher = 'Nintendo'" }
]
} Make a Embedding in an iframeThe SDK automatically creates an iframe with sandbox mode to avoid cross-site issues. You can pass additional sandbox attributes if needed: iframeSandboxExtras: ['allow-top-navigation', 'allow-popups-to-escape-sandbox'] The By following these steps, you can implement login via URL parameters and embed Superset in an iframe while handling cross-site issues [1][2]. |
Beta Was this translation helpful? Give feedback.
-
Guest token is not great as it authenticates to a "guest" user. It'd be great if the embedding SDK supports user access token as well. |
Beta Was this translation helpful? Give feedback.
-
I want to know how we can initiate login via the URL param such as ?username=username&password=password so that via URL users can login
And how can I implement Superset in an Iframe so that there is cross-site problem that is currently facing there
Beta Was this translation helpful? Give feedback.
All reactions