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:
| Mode | Main identity source | Management model |
|---|---|---|
noauth | Local fallback identity or test tenant | No normal user management; supported fallback credentials receive an admin identity. |
db | Keep's local user store | Local sign-in, user creation, password changes, and role updates. |
oauth2proxy | Trusted headers from an OAuth2 Proxy | Proxy supplies the user and group claims; Keep can provision a local record. |
auth0 | Auth0 tokens and user service | Auth0 validates tokens and manages users for multiple tenants. |
keycloak | Keycloak tokens, roles, groups, and authorization data | Keycloak can manage users, groups, roles, resources, and permissions. |
okta | Okta tokens | Authentication works, while user and role management is disabled. |
onelogin | OneLogin tokens and group mappings | SSO works, while user and role management is disabled. |
oidc | A generic OpenID Connect provider | SSO 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. |
azuread | Azure AD tokens and group membership | Azure 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:
- The verifier reads a bearer token, API key, basic credential, digest credential, or trusted identity header.
- The verifier validates the credential and resolves the tenant, user, and role.
- The API dependency checks the role against the required scopes.
- 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:
| Role | Access purpose |
|---|---|
admin | Full read, write, update, delete, and execute access. |
noc | Read access across resources and workflow execution. |
webhook | Write access for alerts and incidents through service keys. |
workflowrunner | Write 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.
| Provider | Identity and role link |
|---|---|
| Auth0 | Validated claims provide the tenant and Keep role. An active tenant is accepted only when the token lists it. |
| Keycloak | Client 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 AD | Configured Azure AD group IDs map to Keep roles. Admin has priority over NOC when both groups are present. |
| OAuth2 Proxy | Forwarded user and group headers map to Keep roles. Configured group mappings and role priority select the result. |
| Okta | Validated token claims provide the tenant, user, and role. Keep uses a default NOC role when no stronger role claim is present. |
| OneLogin | Validated group claims map through configured group names to admin, NOC, or webhook. |
| OpenID Connect | Validated 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:
| Backend | Storage target | Important system behavior |
|---|---|---|
file | A configured local directory | Stores one named value per file. |
db | Keep's database | Stores one value per key and tracks its last update time. |
aws | AWS Secrets Manager | Creates or updates named secrets and can attach tags and rotation settings. |
gcp | Google Cloud Secret Manager | Adds versions and reads the latest version. |
k8s | A Kubernetes Secret in a namespace | Stores the value in the value data field and normalizes names for Kubernetes. |
vault | HashiCorp Vault KV v2 | Supports 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.
Related pages
- Authentication and authorization covers request credentials, token checks, session context, and route authorization.
- Secret management covers secret storage use and backend behavior.
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
| Trigger | Consequence | Guard |
|---|---|---|
AUTH_TYPE names a manager that cannot be loaded | Protected routes cannot create their identity verifier or manager | Keep 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 invalid | The request is rejected as unauthenticated, or the OIDC manager cannot start | Set 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 verification | The request cannot validate its token | Keep the issuer and discovery service available, or configure a valid signing-key endpoint. |
| An OIDC token has no configured group-to-role match | The request receives 403 even when the token is valid | Configure the provider's group claim and map at least one group to a Keep role. |
| A token has no valid tenant, user, or mapped role | The request is rejected before route work. The status is 401 or 403 depending on the failed check | Keep provider claims, tenant membership, and role mappings aligned. |
| A role does not contain a route's required scope | The request receives 403 even after successful authentication | Add the scope to the role or change the route contract deliberately. |
| An enterprise group claim maps to no Keep role | Group-authenticated users cannot enter protected routes | Configure the provider group-to-role mapping and use the expected claim format. |
| A secret backend cannot read a missing or invalid JSON value | Provider setup or workflow context can fail or fall back to an empty secret map | Keep secret names stable and write structured values as valid JSON. |
| Kubernetes secret names contain unsupported characters | The backend cannot create or find the intended secret | Use names that remain correct after underscore replacement and lower-case normalization. |
Key files
| File | Why to read it |
|---|---|
| keep/…/identitymanagerfactory.py | Shows how configuration selects identity managers and verifiers. |
| keep/…/oidc_identitymanager.py | Shows the generic OpenID Connect SSO boundary and the disabled management operations. |
| keep/…/oidc_authverifier.py | Shows OpenID Connect token validation, discovery-based signing-key lookup, group-to-role mapping, and local user updates. |
| keep/…/authverifierbase.py | Shows the shared authenticate-then-authorize request boundary. |
| keep/…/authenticatedentity.py | Defines the identity passed to routes and tenant-aware services. |
| keep/…/rbac.py | Defines the built-in roles and scope matching rules. |
| keep/…/users.py | Shows how user management uses the selected identity manager. |
| keep/…/roles.py | Shows how role management is exposed through protected settings routes. |
| ee/…/keycloak_authverifier.py | Shows multi-organization identity, group role mapping, and external permission checks. |
| keep/…/secretmanagerfactory.py | Shows how the selected secret backend is created. |
| keep/…/secretmanager.py | Defines the backend-neutral secret contract. |
| keep/…/providers_service.py | Shows how provider credentials move into secret storage. |
| keep/…/contextmanager.py | Shows how workflow execution loads its tenant and workflow secret context. |
| keep/…/workflows.py | Shows the protected workflow secret read, write, and delete flow. |