🔐Authentication
To embed a Story, Tile, or Dashboard Builder within your environment, you’ll need to authenticate each embed. Our authentication system is designed to be both secure and flexible. Without duplicating your user database in Toucan, you can pass a user context that dynamically segments data.
Overview

The authentication flow uses the Authorization Grant Flow. Using a combination of credentials and a signed payload (the JWT), Toucan is able to authenticate your embeds and securely handle the embed context.
Embed Manager
Embed Manager Interface
The admin interface allows you to manage embeds and set up authentication.
Path: Admin Area > Embed Manager > Embed Settings


Generate your client secret
Generate a client secret by clicking "Re-generate secret" in the Embed Manager.

Cryptographic keys
You have two methods to manage authentication tokens securely:
RSA Key Pair Management:
Generate and manage a single RSA key pair to sign payloads with the private key. Recommended key strength: at least 2048 bits (in this example, we use 4096 bits).
Once generated, upload the public key to your Toucan admin area.
Uploading another public key will deny the old signed JWTs.
Using a JWKS Endpoint:
If you wish to host the public keys yourself, you can use a JWKS endpoint.
This option allows you to specify multiple public keys, enabling you to rotate keys for enhanced security

Create JWT tokens with user context
To properly initiates the embed, you need to send the embed context and fetch an opaque token (an access token with limited information). To assure integrity and authenticity, the embed context is signed with a private key. The signed payload is called a JWT assertion.
This exchange of JWT should be done on the server side to avoid leaking your private key and client secret to the client.
Here's an example of how to sign an embed context with a private key:
Code example in JS
JWT Token's payload
sub: subject of the JWT. Shared in your Embed Interface settings.
iss: issuer of the JWT. Shared in your Embed Interface settings.
aud: recipient for which the JWT is intended. Shared in your Embed Interface settings.
exp: time after which the JWT expires, in timestamp. Should follow your own authentication expiration policy.
jti: unique identifier; can be used to prevent the JWT from being replayed. You have to generate a random string.
embed_context: object that represents the user and his context. Let's dive in.
username: it will represent your user. We recommend using the user's email but you could also use a unique identifier.
workspace_id: the workspace ID where the user is. The embed manager should show its value in the example.
roles: USER or ADMIN. For your users, we recommend to let USER. For your SDK Key, for instance, ADMIN should be used. (cf. authenticate Embed SDK)
privileges: object that describes your user access's right to apps.
keys are Apps' IDs (cf. find Apps' IDs)
value is an enum on ["view", "validator", "contribute"] (more information in user management section)
groups: user groups defined in Toucan. Can be useful to define visibility rules based on user groups.
attributes: arbitrary variables that give additional context to the user. Most of the time, it includes information that allows data segregation on Live Data implementation.
secrets: variables used to send data to the Toucan tenant that will not be displayed. This section is used for variables that must remain secret, such as passwords or tokens.
Generating the Opaque Token
To fetch an opaque token, use the JWT assertion crafted earlier. This token is opaque because it does not contain sensitive information.
Curl example
Parameters
CLIENT_SECRET: string retrieve after uploading your public key
OAUTH_SERVER_URL: URL of our own authentication service. Shared in the Embed Settings interface.
TENANT_ID: id of your tenant. Shared in the Embed Settings interface.
JWT_TOKEN: token that represents your user, crafted in the previous step.
Example
Static insertion
with eyJ... being your opaque token.
Programmatic insertion
(cf. Embed SDK and Embed SDK Authentication)
SDK_AUTH_TOKEN: A token generated with admin rights to access all your embeds
EMBED_ID: Can be found in the Dashboards tab of your apps, or directly in the Embed Manager.
Last updated
Was this helpful?