fix: clarify GUEST_TOKEN_JWT_AUDIENCE usage in the SDK (#33673)

This commit is contained in:
Zack
2025-06-10 20:41:54 -07:00
committed by GitHub
parent e05ccb3824
commit 59e3645c17
2 changed files with 16 additions and 3 deletions

View File

@@ -116,8 +116,11 @@ Example `POST /security/guest_token` payload:
}
```
Alternatively, a guest token can be created directly in your app with a json like the following, and then signed
with the secret set in configuration variable `GUEST_TOKEN_JWT_SECRET` (see configuration file config.py)
Alternatively, a guest token can be created directly in your app without interacting with the Superset API.
To do this, you should update the `GUEST_TOKEN_JWT_SECRET`
in the Superset [config.py](https://github.com/apache/superset/blob/master/superset/config.py). Also set the
`GUEST_TOKEN_JWT_AUDIENCE` variable that matches what is set for the `aud` in the JSON payload:
```
{
"user": {
@@ -139,6 +142,13 @@ with the secret set in configuration variable `GUEST_TOKEN_JWT_SECRET` (see conf
}
```
In this example, the configuration file includes the following setting:
```python
GUEST_TOKEN_JWT_AUDIENCE="superset"
```
### Sandbox iframe
The Embedded SDK creates an iframe with [sandbox](https://developer.mozilla.org/es/docs/Web/HTML/Element/iframe#sandbox) mode by default

View File

@@ -1806,7 +1806,10 @@ GUEST_TOKEN_JWT_SECRET = "test-guest-secret-change-me" # noqa: S105
GUEST_TOKEN_JWT_ALGO = "HS256" # noqa: S105
GUEST_TOKEN_HEADER_NAME = "X-GuestToken" # noqa: S105
GUEST_TOKEN_JWT_EXP_SECONDS = 300 # 5 minutes
# Guest token audience for the embedded superset, either string or callable
# Audience for the Superset guest token used in embedded mode.
# Can be a string or a callable. Defaults to WEBDRIVER_BASEURL.
# When generating the guest token, ensure the
# payload's `aud` matches GUEST_TOKEN_JWT_AUDIENCE.
GUEST_TOKEN_JWT_AUDIENCE: Callable[[], str] | str | None = None
# A callable that can be supplied to do extra validation of guest token configuration