Skip to content

feat(okta): group-to-role mapping, user auto-provisioning and userinfo enrichment#6574

Open
an0nym21 wants to merge 4 commits into
keephq:mainfrom
an0nym21:feat/okta-group-role-mapping
Open

feat(okta): group-to-role mapping, user auto-provisioning and userinfo enrichment#6574
an0nym21 wants to merge 4 commits into
keephq:mainfrom
an0nym21:feat/okta-group-role-mapping

Conversation

@an0nym21

Copy link
Copy Markdown
Contributor

Summary

  • Add OKTA_ADMIN_GROUPS, OKTA_NOC_GROUPS, OKTA_WEBHOOK_GROUPS env vars to map Okta group membership to Keep roles
  • Call Okta's /v1/userinfo endpoint on each request to retrieve group claims (not present in access tokens by default)
  • Auto-provision users in Keep's DB on first login; update role and last-login on subsequent logins
  • Fix OktaIdentityManager.get_users() which previously returned an empty list
  • Add OKTA_USERINFO_URL env var to override the userinfo endpoint URL
  • Document new env vars in docs/deployment/authentication/okta-auth.mdx

How it works

Okta app-level Group Claims are included in the ID token and userinfo response, but not in the access token. Keep verifies the access token (Bearer), so groups were always empty. This PR calls /v1/userinfo with the Bearer token after JWT verification to retrieve the groups, then resolves the highest-priority matching role.

Role priority: admin > noc > webhook

Configuration example

OKTA_ADMIN_GROUPS=Keep_Admin
OKTA_NOC_GROUPS=Keep_User
OKTA_WEBHOOK_GROUPS=Keep_Webhook

Fixes #6573

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. Documentation Improvements or additions to documentation Feature A new feature labels Jun 11, 2026
an0nym21 added 3 commits June 12, 2026 09:22
Okta group memberships included in the JWT `groups` claim can now be
mapped to Keep roles through environment variables:

  OKTA_ADMIN_GROUPS=keep-admins,platform-team
  OKTA_NOC_GROUPS=keep-noc,ops-team
  OKTA_WEBHOOK_GROUPS=keep-webhooks

When multiple groups match, the highest-privilege role wins
(admin > noc > webhook). If no mapping is configured or no group
matches, the previous fallback chain is preserved:
`keep_role` claim → `role` claim → first group value → "noc" default.

This mirrors the existing KEEP_OAUTH2_PROXY_*_ROLES mechanism and
removes the need to configure custom claims on the Okta authorization
server for group-based setups.

Documentation updated accordingly.
Access tokens from Okta do not include group claims configured at the
app level. Call /v1/userinfo on each request to retrieve groups, name,
and email from the profile — falling back to JWT claims if absent.

Adds OKTA_USERINFO_URL env var to override the default derived URL.
…sioning

Also fix role fallback: unmapped groups should resolve to DEFAULT_ROLE_NAME
when group mappings are configured, not use the raw group name as a role.
@an0nym21 an0nym21 force-pushed the feat/okta-group-role-mapping branch from 1abe3be to e01b9bf Compare June 12, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation Feature A new feature size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Okta group-to-role mapping and user auto-provisioning

1 participant