Repository navigation
docs: document Okta group-to-role mapping #3063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d8c2790
docs: document Okta group-to-role mapping
v0y4g3r 17825a0
docs: state Okta role mapping behavior directly
v0y4g3r be28f66
docs: add Role Management screenshot to Okta role mapping guide
v0y4g3r 39415a4
docs: state Okta org authorization server audience limit
v0y4g3r 321089f
docs: set Okta introspection client_id location in SSO example
v0y4g3r 3ad914b
docs: describe user object fields by identity type
v0y4g3r c86929a
docs: drop rollout policy-mixing note from role mapping guide
v0y4g3r 544a512
docs: list Okta discovery document as a browser endpoint
v0y4g3r 98e69db
docs: qualify SSO display_name default by verification mode
v0y4g3r f6cc364
docs: add authorization_mode to stored user example
v0y4g3r d9c994d
docs: link Okta audience note to custom authorization servers
v0y4g3r File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
305 changes: 305 additions & 0 deletions
305
docs/enterprise/deployments-administration/okta-role-mapping.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,305 @@ | ||
| --- | ||
| keywords: [GreptimeDB Enterprise, Okta, SSO, OIDC, RBAC, role mapping] | ||
| description: Map Okta groups to GreptimeDB Enterprise roles and verify access from the Dashboard. | ||
| --- | ||
|
|
||
| # Map Okta Groups to GreptimeDB Roles | ||
|
|
||
| Use role-based access control (RBAC) to grant GreptimeDB Enterprise permissions | ||
| based on Okta group membership. With the Okta Org Authorization Server, | ||
| GreptimeDB verifies the access token using remote OpenID Connect (OIDC) | ||
| introspection, reads `groups` from UserInfo, and resolves the matching database | ||
| roles. The roles supply the privileges and access control lists (ACLs). | ||
| GreptimeDB identifies the single sign-on (SSO) user by the issuer and `sub` | ||
| and derives that user's permissions during authentication. The SSO identity | ||
| stays out of the user store, and existing password accounts keep working. | ||
|
|
||
| :::note Version compatibility | ||
| This guide applies to Nightly. Use a GreptimeDB Enterprise build that supports | ||
| `jwt_auth.group_role_mapping_file` and an SSO-capable Enterprise Dashboard. | ||
| If you use dashboard-apiserver, use a version that forwards Bearer credentials. | ||
| ::: | ||
|
|
||
| ## 1. Configure the Okta Application | ||
|
|
||
| Follow [Configure Okta](./sso.md#configure-okta) to set up an OIDC | ||
| **Single-Page Application** with Authorization Code + PKCE and | ||
| **Client authentication** set to **None**. Use your Okta org URL as the issuer, | ||
| for example `https://your-org.okta.com`; `/oauth2/default` is a custom | ||
| authorization server outside this guide's scope. Register the exact Dashboard | ||
| sign-in redirect URI, such as | ||
| `https://dashboard.example.com/dashboard/auth/callback`, and note the app's | ||
| client ID. | ||
|
|
||
| Okta's Org Authorization Server issues access tokens for Okta's own resources, | ||
| and its token audience cannot be customized. In remote OIDC mode, GreptimeDB | ||
| binds a token to `jwt_auth.issuer` and `jwt_auth.client_id` through | ||
| introspection and accepts it without checking an audience. Every active Bearer | ||
| access token that Okta issues to this client with the `openid` scope passes | ||
| that check. Deployments that require tokens minted for a dedicated API | ||
| audience need Okta's [custom authorization servers](https://developer.okta.com/docs/concepts/auth-servers/#custom-authorization-server), | ||
| which is outside this guide's scope. | ||
|
|
||
| For this example, use two Okta groups, `greptimedb-alpha-readers` and | ||
| `greptimedb-beta-readers`, with a different test user in each. Assign both groups | ||
| to the application in **Assignments**. Verify the app assignments and group | ||
| memberships separately. If you use existing groups, substitute their names in | ||
| the following steps. | ||
|
|
||
| ## 2. Return Groups from Okta UserInfo | ||
|
|
||
| Open the app's **Sign On** settings and edit **Group Claims** under | ||
| **OpenID Connect ID Token**. If the fields are hidden, expand | ||
| **Show legacy configuration**. Set the claim name to `groups`. | ||
|
|
||
| Choose the claim type by the source of the groups themselves. Check which of | ||
| those groups each user belongs to in **Directory → People**, then check each | ||
| group's source in **Directory → Groups**. A directory-synced user who belongs | ||
| to an Okta-native group uses the same name filter as an Okta-native user. | ||
|
|
||
| - **Okta-native groups only:** Select **Filter → Matches regex**. Match only | ||
| the groups used by this deployment: | ||
|
|
||
| ```text | ||
| ^greptimedb-(alpha|beta)-readers$ | ||
| ``` | ||
|
|
||
| - **Imported or mixed-source groups:** Select **Expression**. Replace the | ||
| placeholders with the Okta group IDs of the groups you want to allow: | ||
|
|
||
| ```text | ||
| getFilteredGroups({"<OKTA_GROUP_ID_1>", "<OKTA_GROUP_ID_2>"}, "group.name", 40) | ||
| ``` | ||
|
|
||
| The expression returns the names of the listed groups that the user belongs | ||
| to. `40` is the per-user result limit. GreptimeDB matches the returned group | ||
| names, so give the allowed groups distinct names. | ||
| See [Okta's static group allowlist guide](https://developer.okta.com/docs/guides/customize-tokens-static/main/). | ||
|
|
||
| - **Groups from one directory with a dedicated prefix:** If matching by name | ||
| is appropriate, use `Groups.startsWith("<DIRECTORY_INSTANCE_ID>", "greptimedb-", 40)` | ||
| as the expression. Use the directory integration's instance ID. Groups with | ||
| that prefix can enter the claim as membership changes. Use the ID allowlist | ||
| above if the set of eligible groups must stay fixed. See | ||
| [Okta's dynamic group allowlist guide](https://developer.okta.com/docs/guides/customize-tokens-dynamic/main/). | ||
|
|
||
| Save the app settings. See [Okta's groups claim guide](https://developer.okta.com/docs/guides/customize-tokens-groups-claim/main/#add-a-groups-claim-for-the-org-authorization-server) | ||
| for the Org Authorization Server. After deploying the `scopes` configuration | ||
| in step 5, sign in with a fresh session. Send the access token as a Bearer | ||
| credential to the discovered UserInfo endpoint (typically `GET /oauth2/v1/userinfo`). | ||
| Verify that the response contains the expected `groups` string array. | ||
| GreptimeDB maps only the `groups` value from this UserInfo response. | ||
|
|
||
| ## 3. Create the GreptimeDB Roles | ||
|
|
||
| Use an existing GreptimeDB administrator to create the roles in the catalog | ||
| where the mapped users will connect. For this example, use the `greptime` | ||
| catalog with two existing tables in the `public` database: | ||
|
|
||
| | Okta group | Role name | Access | | ||
| | --- | --- | --- | | ||
| | `greptimedb-alpha-readers` | `alpha_reader` | `SELECT` on `public.alpha_metrics` | | ||
| | `greptimedb-beta-readers` | `beta_reader` | `SELECT` on `public.beta_metrics` | | ||
|
|
||
| Send `POST /v1/roles` with an operation list and a table ACL. Replace the server | ||
| URL and admin username in this example. `curl` prompts for the admin password. | ||
|
|
||
| ```shell | ||
| curl --include --user '<admin-user>' \ | ||
| 'https://greptimedb.example.com/v1/roles?db=greptime-public' \ | ||
| --header 'Content-Type: application/json' \ | ||
| --data '{ | ||
| "name": "alpha_reader", | ||
| "allowed_ops": ["sql.select"], | ||
| "acl_map": { | ||
| "public": [{"type": "match", "table": "alpha_metrics"}] | ||
| } | ||
| }' | ||
| ``` | ||
|
|
||
| Repeat with `beta_reader` and `beta_metrics`. Each successful request returns | ||
| `201 Created` and the role definition. Check the returned `catalog`, | ||
| `allowed_ops`, and `acl_map`, and record the role `id` for verification. The | ||
| mapping file uses role **names**; the current-user endpoint reports role **IDs**. | ||
|
|
||
| An Enterprise Dashboard with role management lists the created roles and the | ||
| built-in `__ops_*` system roles on the **Role Management** page. The Dashboard's | ||
| role editor changes a role's allowed operations and keeps its existing table | ||
| ACLs, so create the ACLs through the role API as shown above. | ||
|
|
||
|  | ||
|
|
||
| ## 4. Write the Group-to-Role Mapping | ||
|
|
||
| Save this file as `group-roles.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "catalog": "greptime", | ||
| "mapping_field": "groups", | ||
| "roles": { | ||
| "greptimedb-alpha-readers": "alpha_reader", | ||
| "greptimedb-beta-readers": "beta_reader" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| - `catalog` is the catalog where GreptimeDB looks up roles. It defaults to | ||
| `greptime`. Non-admin users must connect to this catalog and a database | ||
| allowed by the mapped roles. | ||
| - `mapping_field` is the exact top-level UserInfo field name. The field's value | ||
| can be a string or an array of strings. | ||
| - `roles` is a non-empty object. Each key matches an Okta claim value exactly, | ||
| including case. Each value names a role in the configured catalog. When | ||
| several groups match, GreptimeDB deduplicates the roles (up to 64) and merges | ||
| their operation grants and ACLs separately. An operation granted by one role | ||
| can apply to a table added by another. Review the combined grants for users | ||
| with multiple roles. | ||
| - An optional `"*"` entry supplies a fallback role only when no explicit group | ||
| matches. It also applies if the claim is missing, `null`, or an empty array. | ||
| A claim with an invalid type is rejected. This example omits the fallback, | ||
| so a user with no matching group is denied. | ||
|
|
||
| Use scoped custom roles for ordinary access. The target `admin` selects the | ||
| built-in administrator role and grants full privileges; `role:admin` refers | ||
| to a custom role literally named `admin`. | ||
|
|
||
| The mapping must be a readable regular file of at most 64 KiB. Use strict JSON: | ||
| the parser rejects unknown fields and duplicate group keys. Limit who can change | ||
| the file, because it controls which roles an Okta user receives. | ||
|
|
||
| ## 5. Configure GreptimeDB and the Dashboard | ||
|
|
||
| Merge the following into the standalone or Frontend TOML configuration. Place | ||
| `user_provider` at the top level before any table. If the enterprise user | ||
| provider is already configured, keep its existing setting. Add the `jwt_auth` | ||
| options to a single plugin entry and replace the issuer and client ID: | ||
|
|
||
| ```toml | ||
| user_provider = "greptime_ee_user_provider:" | ||
|
|
||
| [[plugins]] | ||
| [plugins.jwt_auth] | ||
| issuer = "https://your-org.okta.com" | ||
| client_id = "your-oidc-app-client-id" | ||
| introspection_client_id_location = "query" | ||
| scopes = ["openid", "profile", "email", "groups"] | ||
| display_name = "Okta" | ||
| group_role_mapping_file = "/etc/greptimedb/sso/group-roles.json" | ||
| ``` | ||
|
|
||
| `introspection_client_id_location = "query"` sends `client_id` in the URL query | ||
| for Okta's public-client introspection. Omit `secret`, `public_key`, `jwks_url`, | ||
| `audience`, `algorithm`, and other JWKS settings for remote OIDC. Leave | ||
| `auto_provision` and its privilege and database lists unset: group mapping and | ||
| automatic user provisioning exclude each other, and the Frontend fails to start | ||
| when a configuration combines them. | ||
|
|
||
| The Dashboard uses `scopes` in the OIDC authorization request. Include `openid` | ||
| and `groups`, and keep `profile` for the default UserInfo display name, | ||
| `preferred_username`. Okta must grant the `groups` scope and return the claim | ||
| according to the app's Group Claims settings. | ||
|
|
||
| Serve the Dashboard over HTTPS. Allow the browser to reach Okta's discovery | ||
| document (`<issuer>/.well-known/openid-configuration`), authorization endpoint, | ||
| and token endpoint. Allow GreptimeDB to reach discovery, introspection, and | ||
| UserInfo over trusted HTTPS. If you use dashboard-apiserver, point the instance | ||
| at the configured Frontend and set `enableUserAuthentication: true` in the | ||
| dashboard-apiserver configuration. | ||
|
|
||
| ### Mount the Mapping on Kubernetes | ||
|
|
||
| Create a ConfigMap in the cluster's namespace. Set `NAMESPACE` to that namespace | ||
| before running this command from the directory containing `group-roles.json`: | ||
|
|
||
| ```shell | ||
| kubectl -n "$NAMESPACE" create configmap okta-role-mapping \ | ||
| --from-file=group-roles.json=./group-roles.json | ||
| ``` | ||
|
|
||
| For the [Enterprise Helm deployment](./deploy-on-kubernetes/installation.md), | ||
| merge the TOML into `frontend.configData`. If the deployment sets | ||
| `frontend.configFile`, put the TOML in that file; the chart then builds the | ||
| Frontend configuration from `configFile` alone. If `auth.enabled` is set, | ||
| verify that `auth.useBuiltIn: true` selects the Enterprise user provider. | ||
| Add the mount to the existing Helm values, preserving other volumes and mounts: | ||
|
|
||
| ```yaml | ||
| frontend: | ||
| podTemplate: | ||
| volumes: | ||
| - name: sso-group-roles | ||
| configMap: | ||
| name: okta-role-mapping | ||
| main: | ||
| volumeMounts: | ||
| - name: sso-group-roles | ||
| mountPath: /etc/greptimedb/sso | ||
| readOnly: true | ||
| ``` | ||
|
|
||
| If you manage `GreptimeDBCluster` directly, use `spec.frontend.config` for the | ||
| TOML and `spec.frontend.template` for the volumes and mounts. For deployments | ||
| with [named Frontend groups](/user-guide/deployments-administration/deploy-on-kubernetes/configure-frontend-groups.md), | ||
| configure `config` and `template` on each serving group. | ||
|
|
||
| Mount the directory as shown so its files follow ConfigMap updates. A `subPath` | ||
| mount of the single file keeps the content from container start until the pod | ||
| restarts. For a deployment outside Kubernetes, place the JSON at the configured | ||
| path and give the GreptimeDB process read access. | ||
|
|
||
| ### Roll Out and Update the Mapping | ||
|
|
||
| Apply the Helm or `GreptimeDBCluster` changes and wait for all serving | ||
|
fengjiachun marked this conversation as resolved.
Resolved
|
||
| Frontends to be ready. Outside Kubernetes, restart the configured processes. | ||
|
|
||
| GreptimeDB checks the mapping file during startup, fails to start when the file | ||
| is unreadable or invalid, and reads the file again on each SSO authentication. | ||
| To change the rules, update the ConfigMap or atomically replace the file at the | ||
| same path. A new Bearer-authenticated HTTP request or SQL connection uses the | ||
| updated rules once the change reaches its server. ConfigMap projection takes | ||
| time, so check the file on every replica. If the ConfigMap is immutable, create | ||
| a new one and roll out the updated volume reference. Existing SQL connections | ||
| keep their session permissions; close those connections if you need immediate | ||
| revocation. Changing the TOML or mapping path requires a restart. | ||
|
|
||
| ## 6. Verify and Troubleshoot | ||
|
|
||
| 1. Check `GET /v1/auth/config` directly or through the | ||
| [Dashboard proxy](./sso.md#how-it-works). Confirm `auth_required: true` | ||
| and that the `oidc` method advertises your issuer, client ID, and `groups` | ||
| scope. | ||
| 2. Use a fresh browser session for each test user. Sign in with Okta and check | ||
| `GET /v1/users/current?db=greptime-public`. The response should have | ||
| `auth_source: "sso"` and the expected `role_ids` from step 3. | ||
| 3. In the `public` database, run `SELECT * FROM public.alpha_metrics LIMIT 1` | ||
| and `SELECT * FROM public.beta_metrics LIMIT 1` separately. For a user in | ||
| just one group, the corresponding query should succeed and the other should | ||
| be denied (`403` over HTTP). | ||
| 4. Try an app-assigned user with no matching group. With no `"*"` rule, that | ||
| user's Bearer requests should be rejected (`401` over HTTP). | ||
| 5. To test a mapping update, change one rule in a test environment. Once the | ||
| new file has reached the Frontends, repeat the HTTP checks with the same | ||
| unexpired token. Verify the new role IDs and SQL results, then restore the | ||
| original mapping. | ||
|
|
||
| At startup, the Frontend log `Bearer authentication configured` should show | ||
| `verification="oidc_introspection"` and `identity_resolution="group_role_mapping"`. | ||
| For troubleshooting, temporarily set `[logging]` `level` to | ||
| `"info,user_server=debug"` on the affected server. If Helm manages logging, add | ||
| `user_server=debug` to `frontend.logging.filters`. Use the following | ||
| stages to find the failing check: | ||
|
|
||
| | Symptom or log stage | What to check | | ||
| | --- | --- | | ||
| | Only password login appears | Check dashboard-apiserver's `enableUserAuthentication` setting, the instance's Frontend address, and the raw `/v1/auth/config` response. | | ||
| | `introspection` or `userinfo` | Check issuer, client ID, `query` placement, HTTPS connectivity, and that the access token is valid. UserInfo must include `sub` and the configured display-name claim. | | ||
| | `group_mapping_file` | Check the actual file path and mount on the serving Frontend, file permissions, size, and JSON syntax. | | ||
| | `group_selection` | Check the app assignment, actual group membership, granted scope, UserInfo claim type, and exact group names. Sign in again after changing group claim settings. | | ||
| | `role_lookup` | Confirm the mapped role names exist in the specified catalog. | | ||
| | `/v1/users/current` succeeds but a query is denied | Check the role's operation grants and database/table ACLs for that query. | | ||
| | Different replicas return different permissions | Check that all Frontends have the same configuration and have received the updated file. | | ||
|
|
||
| Restore the normal log level after troubleshooting. Remove access tokens, ID | ||
| tokens, passwords, and OAuth callback URLs before sharing logs or filing a | ||
| support request. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.