Examples of an OIDC configuration in DataLens On-premises
Keycloak
Example of a Keycloak configuration
const keycloakConfig = {
slug: 'keycloak',
title: 'Keycloak',
type: 'oidc',
defaultRole: 'datalens.visitor',
config: {
issuer: 'https://keycloak.example.org/realms/datalens-enterprise/.well-known/openid-configuration',
clientId: 'datalens',
clientSecret: 'password',
codeChallengeMethod: 'S256',
scope: ['openid', 'profile', 'email', 'roles', 'groups'],
roles: {
path: 'resource_access.datalens.roles',
targetType: 'array-of-strings',
mapping: {
'datalens.admin': 'client.datalens.admin',
'datalens.creator': 'client.datalens.creator',
},
},
syncUserRoles: true,
groups: {
path: 'groups',
targetType: 'array-of-strings', // We recommend that you configure Script Mapper and use 'array-of-objects' to specify the group ID and name
},
syncUserGroups: true,
},
};
Keycloak client settings
Set up a Keycloak client configuration for this example:
-
Specify the client settings by clicking
Clients→ your client (datalens) →Settings:- Valid redirect URIs:
{UI_APP_ENDPOINT}/auth/callback/oidc. ReplaceUI_APP_ENDPOINTwith your app URL, such ashttp://example.com:8080/auth/callback/oidc. - Client authentication:
on. - Authentication flow:
Standard flow.
- Valid redirect URIs:
-
To create roles, click
Clients→ your client (datalens) →Roles:client.datalens.adminclient.datalens.creator
-
To create a group, click
Groups→Create group. -
To assign a group and roles to a user, click
Users→user.- Assign the roles on the
Role mappingtab. - Assign the roles on the
Groupstab.
- Assign the roles on the
-
To set the client scope, click
Client scopes→Create client scope.- Create the
groupsscope andGroup Membershipmapper type. EnableAdd to userinfoin the Keycloak settings. - Create the
rolesscope orclient rolespredefined mapper. EnableAdd to userinfoin the Keycloak settings.
- Create the
Example of userinfo for Keycloak
{
"sub": "4d2b6d80-49cf-44fb-94c6-946393dea8c7",
"resource_access": {
"datalens": {
"roles": [
"client.datalens.creator"
]
},
},
"email_verified": true,
"name": "Bob Smith",
"groups": [
"datalens-admin"
],
"preferred_username": "bob",
"given_name": "Bob",
"family_name": "Smith",
"email": "bob@example.org"
}
Example of configuration via the AUTH_PROVIDERS_CONFIG environment variable
To configure authentication providers, the application uses the AUTH_PROVIDERS_CONFIG environment variable. This variable contains a JSON string with an array of configurations of all authentication providers.
Example of the AUTH_PROVIDERS_CONFIG environment variable:
[
{
"slug": "keycloak",
"title": "Keycloak",
"type": "oidc",
"defaultRole": "datalens.visitor",
"config": {
"issuer": "https://keycloak.example.org/realms/datalens-enterprise/.well-known/openid-configuration",
"clientId": "datalens",
"clientSecret": "password",
"codeChallengeMethod": "S256",
"scope": ["openid", "profile", "email", "roles", "groups"],
"roles": {
"path": "resource_access.datalens.roles",
"targetType": "array-of-strings",
"mapping": {
"datalens.admin": "client.datalens.admin",
"datalens.creator": "client.datalens.creator"
}
},
"syncUserRoles": true,
"groups": {
"path": "groups",
"targetType": "array-of-strings"
},
"syncUserGroups": true
}
}
]
Previous