Introducing a new way to review your PRs.

Read the announcement

keephq / keep

The open-source AIOps and alert management platform

View on GitHub

22 documents · Updated Nov 23, 2026

docs / identity-access-and-secrets

Identity, access, and secrets

Keep separates request identity, access decisions, and secret storage. An identity manager selects the active sign-in system and its verifier. The verifier turns a valid request into an authenticated entity, then checks the entity's role against the scopes required by the API operation. A separate secret manager stores provider and workflow credentials without tying the rest of the system to one storage service.

Identity manager boundary

The identity manager is the system boundary for user life-cycle actions and authentication-provider access. keep/…/identitymanagerfactory.py selects one manager from AUTH_TYPE, then the API asks that manager for an authentication verifier and for tenant-scoped user, group, role, or permission data.

The available identity modes serve different operating needs:

ModeMain identity sourceManagement model
noauthLocal fallback identity or test tenantNo normal user management; supported fallback credentials receive an admin identity.
dbKeep's local user storeLocal sign-in, user creation, password changes, and role updates.
oauth2proxyTrusted headers from an OAuth2 ProxyProxy supplies the user and group claims; Keep can provision a local record.
auth0Auth0 tokens and user serviceAuth0 validates tokens and manages users for multiple tenants.
keycloakKeycloak tokens, roles, groups, and authorization dataKeycloak can manage users, groups, roles, resources, and permissions.
oktaOkta tokensAuthentication works, while user and role management is disabled.
oneloginOneLogin tokens and group mappingsSSO works, while user and role management is disabled.
oidcA generic OpenID Connect providerSSO works through token and group claims. Keep maps groups to roles and can create or update a local user record. Identity management stays with the provider.
azureadAzure AD tokens and group membershipAzure AD supplies identity and role. Keep keeps a local user record.

Older values such as single_tenant, no_auth, and multi_tenant map to current manager names. If a requested manager is not available, startup or request setup fails instead of silently selecting another provider. keep/…/identitymanagerfactory.py defines this selection boundary.

Authenticated entity

An authenticated entity is the common identity record passed from authentication into authorization and tenant-aware business code. keep/…/authenticatedentity.py defines its core fields as tenant_id, email, an optional API key name, and an optional role. Extra fields are allowed so an enterprise provider can carry context such as an organization, realm, token, or list of user organizations.

The request path uses this record as a hand-off:

  1. The verifier reads a bearer token, API key, basic credential, digest credential, or trusted identity header.
  2. The verifier validates the credential and resolves the tenant, user, and role.
  3. The API dependency checks the role against the required scopes.
  4. The route uses the authenticated entity's tenant to load or change data.

This keeps provider-specific claims at the identity boundary. Downstream routes can use one identity shape even when the source is a local account, an API key, or an enterprise token. keep/…/authverifierbase.py defines the shared request sequence.

Role-based access control

Role-based access control (RBAC) grants a set of action and resource scopes to a named role. A scope uses the action:resource form, such as read:workflows or write:secrets. API routes declare the scopes they need through the authentication dependency, so authentication and access checks occur before the route handles the request. keep/…/workflows.py shows the same contract for workflow data and workflow secrets.

The built-in roles cover human and service access:

RoleAccess purpose
adminFull read, write, update, delete, and execute access.
nocRead access across resources and workflow execution.
webhookWrite access for alerts and incidents through service keys.
workflowrunnerWrite and execute access for workflows through service keys.

Role checks accept an exact scope or an action wildcard such as read:*. The base verifier returns 401 when the request has no valid identity and 403 when the identity lacks a required scope. keep/…/rbac.py and keep/…/authverifierbase.py define the shared role and scope rules.

The authorization model has two levels. Route scopes protect broad API operations. Keycloak can add resource-level decisions for specific objects through its authorization service, while API-key requests use the shared RBAC path because they do not carry a Keycloak token. ee/…/keycloak_authverifier.py and ee/…/keycloak_identitymanager.py define this enterprise extension.

Enterprise identity extensions

Enterprise identity providers extend the common entity model with claims that connect an external identity to Keep tenants and roles. Token validation remains provider-specific, but each verifier must return the same authenticated entity and must resolve a Keep role before protected work can proceed.

ProviderIdentity and role link
Auth0Validated claims provide the tenant and Keep role. An active tenant is accepted only when the token lists it.
KeycloakClient roles provide single-tenant access. Group names can represent organizations and roles for multi-tenant access. Keycloak UMA can check route and object permissions.
Azure ADConfigured Azure AD group IDs map to Keep roles. Admin has priority over NOC when both groups are present.
OAuth2 ProxyForwarded user and group headers map to Keep roles. Configured group mappings and role priority select the result.
OktaValidated token claims provide the tenant, user, and role. Keep uses a default NOC role when no stronger role claim is present.
OneLoginValidated group claims map through configured group names to admin, NOC, or webhook.
OpenID ConnectValidated tokens provide the user identity. A configured group claim maps external groups to admin, NOC, or webhook. Admin has priority. The verifier discovers and caches the provider's signing-key endpoint and refreshes provider keys when the token key changes.

Some enterprise modes auto-provision or update a local user record after a successful sign-in. This record supports Keep's user view and sign-in tracking. It does not replace the external provider as the source of authentication. ee/…/auth0_authverifier.py, ee/…/azuread_authverifier.py, keep/…/oauth2proxy_authverifier.py, keep/…/okta_authverifier.py, and keep/…/onelogin_authverifier.py describe these provider links.

Generic OpenID Connect follows the same boundary. The provider remains responsible for sign-in and group membership. Keep validates an RS256-signed token against the configured issuer and audience, maps a group to a Keep role, and can create or update a local record on each request. The signing-key endpoint comes from OpenID Connect discovery unless an explicit endpoint is configured. keep/…/oidc_authverifier.py and keep/…/oidc_identitymanager.py define this provider link.

Keycloak also supports organization-aware identity. Group claims can create or locate Keep tenants, expose the user's organizations to the UI, and choose the active tenant. A token that names an active tenant without the matching organization membership or role is rejected. ee/…/keycloak_authverifier.py defines this tenant selection behavior.

Secret manager boundary

The secret manager is a storage boundary for values that must not remain in ordinary provider or workflow records. Every backend implements the same read, write, and delete contract. keep/…/secretmanagerfactory.py selects the backend from SECRET_MANAGER_TYPE, with file storage as the default.

The supported backends map the common contract to different stores:

BackendStorage targetImportant system behavior
fileA configured local directoryStores one named value per file.
dbKeep's databaseStores one value per key and tracks its last update time.
awsAWS Secrets ManagerCreates or updates named secrets and can attach tags and rotation settings.
gcpGoogle Cloud Secret ManagerAdds versions and reads the latest version.
k8sA Kubernetes Secret in a namespaceStores the value in the value data field and normalizes names for Kubernetes.
vaultHashiCorp Vault KV v2Supports a Vault token or Kubernetes login.

Callers work with secret names and values rather than backend APIs. Provider installation stores provider authentication data under a generated secret name and keeps that name in the provider record. Workflow secret APIs store one JSON object per tenant and workflow, then read or update keys inside that object. keep/…/providers_service.py, keep/…/workflows.py, and keep/…/contextmanager.py show these two uses.

The read contract can return a string or parse a JSON value when the caller requests it. This lets a workflow context load its secret map and lets provider code recover structured authentication data without knowing whether the value came from a file, database, or external secret service. keep/…/secretmanager.py defines the contract.

Change checklist

When these files or sections are changed, remember to consider these:

  • A new identity mode must be available to both identity-manager and verifier loading, and its verifier must return the fields expected by tenant-aware routes.
  • A new role or scope must stay aligned across route dependencies, predefined role expansion, enterprise provider mappings, and any external authorization model.
  • Changes to authenticated-entity fields must preserve provider-specific extensions and the tenant value used by downstream data and secret lookups.
  • Changes to secret naming or JSON shape must be checked against provider records, workflow context loading, and all read, update, and delete paths.
  • A new secret backend must implement the full read, write, and delete contract and be selectable through the factory without changing callers.

Important failure modes

TriggerConsequenceGuard
AUTH_TYPE names a manager that cannot be loadedProtected routes cannot create their identity verifier or managerKeep the configured type in the factory's supported set and provide the required provider settings.
OIDC configuration is missing or its token issuer, audience, signature, or expiry is invalidThe request is rejected as unauthenticated, or the OIDC manager cannot startSet the required issuer and client ID. Keep the provider token settings aligned with Keep.
The OIDC discovery document has no signing-key endpoint or the provider cannot be reached on first verificationThe request cannot validate its tokenKeep the issuer and discovery service available, or configure a valid signing-key endpoint.
An OIDC token has no configured group-to-role matchThe request receives 403 even when the token is validConfigure the provider's group claim and map at least one group to a Keep role.
A token has no valid tenant, user, or mapped roleThe request is rejected before route work. The status is 401 or 403 depending on the failed checkKeep provider claims, tenant membership, and role mappings aligned.
A role does not contain a route's required scopeThe request receives 403 even after successful authenticationAdd the scope to the role or change the route contract deliberately.
An enterprise group claim maps to no Keep roleGroup-authenticated users cannot enter protected routesConfigure the provider group-to-role mapping and use the expected claim format.
A secret backend cannot read a missing or invalid JSON valueProvider setup or workflow context can fail or fall back to an empty secret mapKeep secret names stable and write structured values as valid JSON.
Kubernetes secret names contain unsupported charactersThe backend cannot create or find the intended secretUse names that remain correct after underscore replacement and lower-case normalization.

Key files

FileWhy to read it
keep/…/identitymanagerfactory.pyShows how configuration selects identity managers and verifiers.
keep/…/oidc_identitymanager.pyShows the generic OpenID Connect SSO boundary and the disabled management operations.
keep/…/oidc_authverifier.pyShows OpenID Connect token validation, discovery-based signing-key lookup, group-to-role mapping, and local user updates.
keep/…/authverifierbase.pyShows the shared authenticate-then-authorize request boundary.
keep/…/authenticatedentity.pyDefines the identity passed to routes and tenant-aware services.
keep/…/rbac.pyDefines the built-in roles and scope matching rules.
keep/…/users.pyShows how user management uses the selected identity manager.
keep/…/roles.pyShows how role management is exposed through protected settings routes.
ee/…/keycloak_authverifier.pyShows multi-organization identity, group role mapping, and external permission checks.
keep/…/secretmanagerfactory.pyShows how the selected secret backend is created.
keep/…/secretmanager.pyDefines the backend-neutral secret contract.
keep/…/providers_service.pyShows how provider credentials move into secret storage.
keep/…/contextmanager.pyShows how workflow execution loads its tenant and workflow secret context.
keep/…/workflows.pyShows the protected workflow secret read, write, and delete flow.