Identity and team access
Identity and team access control who may use the cloud control plane, what each identity may do, and which projects each team may reach. The system combines browser sessions, machine credentials, role and permission checks, team grants, step-up checks for sensitive work, audit records, OIDC single sign-on, and proof-of-work protection for public workloads. See the cloud control plane for the wider platform model and cloud client and protocol for client and API communication.
Access model
The access model first establishes the caller identity. It then checks permissions and resource scope before an operation can proceed.
flowchart TD
A[Request] --> B{Credential source}
B -->|Browser session| C[User identity and role]
B -->|API or CLI key| D[User identity and key grant]
B -->|Deployment token| E[Project-scoped machine identity]
C --> F[Required permission]
D --> F
E --> F
F --> G{Project operation?}
G -->|No| H[Allow or deny]
G -->|Yes| I[Project scope and team access]
I --> H
Authentication sources
Browser requests use an encrypted session cookie. Programmatic requests use bearer credentials. A deployment token identifies a project instead of a person. CLI users start an interactive device flow in the browser.
Password login and OIDC login lead to the same full-session boundary. An MFA account first receives a short-lived pending challenge. That challenge cannot authenticate a normal request. A required first-login password change is another short-lived browser flow, and an administrator reset removes existing sessions before the user chooses a new password.
API keys carry a role or custom permission set. Validation caps the stored grant by the owner's current role, so a later role downgrade also narrows the key. Invalid identifiers and unknown accounts receive the same public credential error, while bounded identity data remains available for audit review.
| Source | Identity carried | Main boundary |
|---|---|---|
| Browser session | User account and session record | Acts as the user for console operations. |
| API key or CLI credential | User account plus key permissions | Cannot exceed the owner's current rights. |
| Deployment token | Project and optional environment or deployment | Has no user identity and stays inside its project. |
References: crates/…/middleware.rs• L129-257 crates/…/context.rs• L59-89 crates/…/auth_service.rs• L257-364 crates/…/apikey_service.rs• L383-465 crates/…/handlers.rs• L1077-1507
CLI device authorization
CLI device authorization links a terminal to an authenticated browser session. The CLI creates a short-lived request and polls while the user reviews it in the browser. Approval requires a browser session with API-key creation permission and the required sensitive-action assurance.
Approval mints a new API key under the approver's effective ceiling. The CLI receives the key once through a locked claim step. The pending request expires, and stored key material is encrypted until delivery. Machine credentials cannot approve a device login even when the general step-up policy lets them pass.
References: crates/…/cli_device_handler.rs• L4-31 crates/…/cli_device_handler.rs• L362-431 crates/…/cli_device_handler.rs• L479-639 crates/…/cli_device_handler.rs• L719-817
OIDC provider management
OIDC provider management connects the control plane to enterprise identity providers without removing password login. Each enabled provider has a login path and a callback that resolves the external identity into a local user.
An OIDC login state is short-lived and single-use. PKCE, a nonce, and a browser binding connect the callback to the login that started it. Same-origin relative return paths keep the final redirect inside the console. Discovery and token exchange use a bounded client with no redirects. Issuer destinations are checked before contact and again when a connection is made; private destinations need an explicit trusted-network policy.
Provider policy controls account linking and provisioning. Just-in-time provisioning can create a user. Group and role claims can map to a platform role. Existing-account linking and new-user creation require email_verified by default. A trusted corporate provider can bypass that claim check. Ordered mapping rules use first match, wildcard fallback, and provider default role.
The Cloud-managed provider is protected. Cloud provisions its provider and mappings as one unit. Only Cloud owner and admin claims can pass its administrator-only gate. An ordinary provider cannot reuse its issuer. Disable and delete remove pending login states and linked sessions, while callback and MFA completion check provider trust again.
OIDC failures expose short safe codes to browsers and keep detailed errors in server logs. A managed-provider role denial receives its own audit event.
References: crates/…/oidc_handler.rs• L53-154 crates/…/oidc_handler.rs• L318-485 crates/…/oidc_service.rs• L1082-1281 crates/…/oidc_service.rs• L1283-1456 crates/…/oidc_service.rs• L582-707 crates/…/oidc_service.rs• L760-963 crates/…/oidc_service.rs• L1973-2068 crates/…/oidc_errors.rs• L134-271
Authorization layers
Authorization checks a required instance permission first. A project operation then adds project scope and may narrow the permission to rights from the caller's project role.
Instance roles provide broad permission sets. The effective permission set is the contract for an operation, so a role name alone does not describe every allowed action. Project permissions intersect with instance permissions; a project role can remove a right but cannot add one. Checker errors fail closed.
Deployment-token permissions are separate from control-plane permissions. Even FullAccess covers only explicitly mapped deployment capabilities. The token's project must match the project in the request. Missing credentials fail authentication. Known identities without a required permission receive a forbidden result.
References: crates/…/context.rs• L20-49 crates/…/context.rs• L227-294 crates/…/context.rs• L304-467 crates/…/temps_middleware.rs• L118-242 crates/…/apikey_handler.rs• L45-125
Team membership
Teams are the unit for sharing project access among users. A team has members, and a project grant gives that team a project role. Effective access is limited by both relationships.
Team and project grants
A project with no grants remains open to authenticated callers with the required instance permission. The first grant makes it team-gated. Team creation, membership changes, team roles, and project grants are separate administrative actions. The console distinguishes an empty team list from a failed team read.
| Project role | Purpose | Boundary |
|---|---|---|
viewer | Read project resources | Cannot change or delete resources. |
deployer | Ship code and change deployment inputs | Cannot delete resources or change project settings. |
admin | Operate the project | Cannot delete the project itself. |
owner | Control the project | Includes project deletion. |
References: crates/…/teams.rs• L8-29 crates/…/team_members.rs• L8-29 crates/…/project_team_access.rs• L8-26 crates/…/teams.rs• L196-212 crates/…/project_access.rs• L82-92 web/…/TeamFieldHint.tsx• L6-42
Project permission resolution
For a team-gated project, the checker requires membership in a team granted to that project. If grants exist but the user belongs to none of those teams, access is denied. Matching project roles then narrow the caller's instance permissions.
Instance Admin and PlatformAdmin callers bypass team membership checks. Deployment tokens use exact project matching instead. Access errors deny the request rather than allowing it when backing data is unavailable.
References: crates/…/checker.rs• L4-78 crates/…/permission_guard.rs• L45-133 crates/…/permission_guard.rs• L239-447 crates/…/role_permissions.rs• L19-129
User and role administration
User administration manages accounts and instance roles. General user writes are separate from role-changing power. The latter uses users:manage, so a caller that can edit user records cannot automatically create or assign an administrator role. Callers cannot change their own role or delete their own account.
Role changes affect the permissions used by protected operations. User creation resolves all requested roles before writing the account and assignments. Administrator password reset returns a temporary password once, marks a first-login change, and revokes existing sessions.
References: crates/…/handlers.rs• L1994-2189 crates/…/handlers.rs• L2209-2271 crates/…/handlers.rs• L2293-2418 crates/…/handlers.rs• L2524-2735 crates/…/user_service.rs• L610-849 crates/…/user_service.rs• L851-1032
Sensitive operations
Some operations need more assurance than a valid session and permission. The platform uses MFA during login and a short session-bound step-up check for sensitive browser actions.
MFA and step-up verification
A successful step-up verifies TOTP or a recovery code and elevates only the current browser session for five minutes. It does not change the user's role. The shared MFA rules prevent TOTP reuse, consume recovery codes once, count failures per user, and apply growing lockouts. MFA seeds are encrypted at rest.
The default policy challenges an enrolled browser user without recent elevation. Users without enrolled MFA pass because there is no factor to re-check. API keys, CLI credentials, and deployment tokens also pass this interactive check; their permission and resource scope remain in force. A stronger policy can change this behavior. Password-login MFA settings do not enforce enrollment for OIDC users by themselves.
Sensitive actions include API-key creation, CLI device approval, OIDC provider changes, role assignment, account-email changes, other-user password reset, and team deletion. These actions still require their normal permissions. MFA enrollment requires the current password for password-backed accounts and can proceed without one for SSO-only accounts. Disabling MFA clears old step-up elevation.
References: crates/…/mfa_guard.rs• L4-45 crates/…/mfa_guard.rs• L205-259 crates/…/mfa_guard.rs• L413-485 crates/…/sensitive_action.rs• L17-93 crates/…/sensitive_action.rs• L104-207 crates/…/sensitive_action.rs• L240-355 crates/…/handlers.rs• L314-708 crates/…/user_service.rs• L1034-1208
Machine credentials and access ceilings
Machine credentials support automation without treating automation as an interactive user. API keys retain their owner and carry a role or custom grant. Deployment tokens carry deployment permissions and bind to a project, environment, or deployment.
API-key creation, update, and rotation cannot grant more than the presented principal holds. Validation also caps the stored grant by the owner's current role. Deployment tokens cannot become platform administrators or use unrelated user, settings, or system APIs. Deactivation stops a key, and rotation replaces the old secret while returning the new secret only once.
References: crates/…/context.rs• L227-294 crates/…/context.rs• L446-467 crates/…/apikey_handler.rs• L45-125 crates/…/apikey_handler.rs• L291-309 crates/…/apikey_handler.rs• L435-480 crates/…/apikey_service.rs• L188-277 crates/…/apikey_service.rs• L383-465
Audit trail
The audit trail records security and access changes so an operator can reconstruct who acted, when, and from which request context. It keeps operation data with actor, user-agent, IP, and time details when known. It also distinguishes a resolved identity rejected by policy from credentials that never resolved to an account.
Security event coverage
Authentication records successful and failed logins, MFA results, logout, password reset, concurrent-session detection, CLI device approvals, and step-up results. Identity records include user and role changes, API-key creation and rotation, OIDC provider and mapping changes, team membership changes, and project access changes. Permission denials are recorded with safe server-derived data such as source, credential identifier when clear, route template, method, denial kind, required permission, and request origin.
Repeated denials are aggregated within bounded storage. Mixed credentials or origins clear singular attribution. Login failures retain a bounded normalized claimed email when no account resolves. Secrets, temporary passwords, and MFA codes are not stored. An OIDC role-gate denial has no local actor because it is rejected before session creation.
References: crates/…/handlers.rs• L49-216 crates/…/handlers.rs• L1293-1460 crates/…/oidc_handler.rs• L407-485 crates/…/cli_device_handler.rs• L595-607 crates/…/temps_middleware.rs• L213-365
Audit access
Reading the audit trail requires audit:read. The standard roles with that permission are Admin and PlatformAdmin; project team roles do not receive platform-wide audit access. The audit API supports filtered and paged reads, and the console hides the audit page from callers without access.
References: crates/…/handlers.rs• L33-130 crates/…/audit_service.rs• L182-279 crates/…/permissions.rs• L776-784 web/…/useAuditAccess.ts• L7-21 web/…/AuditLogs.tsx• L328-549
CAPTCHA protection
CAPTCHA support protects public deployed workloads during attack mode. It does not authenticate a user or grant team access. It records only that a short-lived challenge was solved for an environment and client identifier.
Proof-of-work challenge
When attack mode blocks a request, the proxy identifies the caller by TLS fingerprint when available or by IP address. The browser solves a SHA-256 proof-of-work challenge and sends the challenge and nonce to a verification endpoint. A valid solution marks that environment and identifier as complete for a limited period.
The browser normally uses a WebAssembly solver and can fall back to JavaScript. The server checks the solution itself, so the client solver changes speed but not trust.
References: crates/…/captcha.rs• L4-18 crates/…/captcha.rs• L26-118 crates/…/lib.rs• L81-167 crates/…/challenge_service.rs• L13-35 crates/…/challenge_service.rs• L132-211
Attack-mode boundary
Attack mode is selected at project or environment level. CAPTCHA verification and solver assets remain reachable so a blocked visitor can complete the challenge. Other requests require HTTPS and a valid challenge before the proxy forwards them.
This boundary sits in front of the deployed workload rather than inside the control-plane identity system. A solved challenge does not grant console access, project permissions, team membership, or a bearer token.
References: crates/…/proxy.rs• L4541-4661 crates/…/proxy.rs• L4803-4807 crates/…/challenge_service.rs• L200-295
Platform security controls
Platform security settings add request, browser, and proxy-client boundaries beside identity checks. They reduce abuse and unsafe browser or network behavior. They do not replace authentication or authorization.
Security headers and rate limits
Administrators can apply security headers through presets or custom values. Rate limits can cap requests by IP over minute and hour windows. IP allow and block rules can bypass a limit for trusted networks or refuse unwanted networks before application work.
References: web/…/SecuritySettings.tsx• L33-94 web/…/SecuritySettings.tsx• L159-221 web/…/SecuritySettings.tsx• L345-461 web/…/SecurityPage.tsx• L175-181
Administrative access gate
The security settings page exposes an extra verification gate for sensitive administrative actions. This gate is separate from the role check, so an administrator must still hold the required permission.
References: web/…/SecurityPage.tsx• L135-143
Proxy client identity
The security settings page controls whether the proxy trusts forwarded client-IP headers from a loopback reverse proxy. This supports accurate analytics and IP controls only when the trusted proxy controls those headers. The setting reaches proxy processes shortly after it is saved.
References: web/…/SecurityPage.tsx• L144-174
Change checklist
When these files or sections are changed, remember to consider these:
- Keep each protected operation aligned across its required permission, project access check, deployment-token scope, and sensitive-action policy.
- Keep instance roles, API-key ceilings, current-owner caps, and project-role intersections from widening access through an alternate credential path.
- Keep deployment-token permission mappings aligned with both token use and token grant checks.
- Keep project and team access writes coupled to access-cache invalidation after commit.
- Keep identity, team, role, provider, key, login-failure, MFA, and denial changes mapped to safe audit events.
- Keep denial aggregation safe when one window contains multiple credentials or origins. Do not store raw request URIs.
- Keep OIDC browser binding, atomic state use, PKCE, nonce checks, issuer checks, timeouts, redirect policy, and connect-time address checks aligned.
- Keep OIDC claim rules, email trust, role mappings, wildcard fallback, and provider default role aligned.
- Keep the Cloud-managed provider's issuer uniqueness, administrator-only gate, protected mappings, transactional provisioning, and revocation aligned.
- Keep provider disable and delete coupled to pending-login cleanup, active-session revocation, callback checks, and MFA completion checks.
- Keep CLI device approval restricted to browser sessions. Keep key ceilings, encryption, expiry, and one-time delivery coupled to the flow.
- Keep the default step-up policy clear: enrolled browser users need recent verification, while unenrolled users and machine credentials pass unless a stronger policy is configured.
- Keep MFA replay state, recovery-code consumption, failure counters, secret encryption, and session elevation in one shared contract.
- Keep CAPTCHA hashing, verification, difficulty, identifier type, lifetime, and both client solvers in sync.
- Keep trusted forwarded-IP behavior aligned with the reverse proxy. Untrusted headers allow IP-control spoofing.
- Keep user and team read failures distinct from verified empty results.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A deployment token names a different project than the request | The request is rejected. | The token project is compared with the request project. |
| A user without a team grant requests a gated project | The project operation is forbidden. | The checker requires membership in a granted team. |
| A project role lacks the required permission | The user can reach the project but cannot perform the operation. | Project rights intersect with instance rights. |
| An access checker fails | The request is denied instead of allowed. | Project guards fail closed. |
| An API key requests rights above the presented principal's rights | The key write is refused. | Key creation, update, and rotation enforce a permission ceiling. |
| An API-key owner is later demoted | The key loses the permissions no longer held by the owner. | Validation caps the stored grant by the current owner role. |
| An enrolled browser user has no recent step-up | The sensitive action asks for verification. | Elevation is tied to the active session and expires after five minutes. |
| A pending MFA challenge is used as a normal session | Authentication fails. | Normal session verification excludes pending rows. |
| An OIDC callback uses unknown, reused, expired, or foreign browser state | Login fails. | State is single-use, time-limited, and bound to its starting browser. |
| An OIDC issuer resolves to a blocked internal address | Discovery or token exchange is refused. | Pre-request and connect-time address checks reject it. |
| A managed OIDC identity resolves to a non-admin role or malformed role claim | Login is refused and the denial is audited. | The managed provider uses a strict administrator-only gate. |
| A provider is disabled during login or MFA | No lasting session is created. | Pending states and sessions are revoked and provider status is re-checked. |
| Attack mode receives HTTP or an unsolved workload request | The proxy asks for HTTPS or a challenge. | Only CAPTCHA routes bypass the gate. |
| A reverse proxy passes untrusted forwarded-IP headers | Clients can spoof IP controls. | Trust is enabled only for a header-controlling proxy. |
| Sensitive-action policy evaluation fails | The protected operation does not run. | Policy errors fail closed. |
Key files
| File | Why to read it |
|---|---|
| crates/…/middleware.rs | Shows how sessions, API keys, and deployment tokens become authentication context. |
| crates/…/context.rs | Defines identity sources, token scope, and permission boundaries. |
| crates/…/apikey_handler.rs | Shows key permission ceilings and sensitive key actions. |
| crates/…/apikey_service.rs | Shows key lifecycle, current-owner capping, expiry, and validation. |
| crates/…/permissions.rs | Defines instance roles and permissions. |
| crates/…/permission_guard.rs | Shows permission, project, team, and project-role checks. |
| crates/…/mfa_guard.rs | Defines shared MFA replay, recovery, encryption, and lockout rules. |
| crates/…/sensitive_action.rs | Defines browser step-up and machine-principal policy. |
| crates/…/auth_service.rs | Shows session, password, MFA, and provider-trust boundaries. |
| crates/…/user_service.rs | Shows user, role, password, and MFA lifecycle behavior. |
| crates/…/handlers.rs | Shows login, user administration, MFA, and audit boundaries. |
| crates/…/cli_device_handler.rs | Shows browser-approved CLI login and one-time key delivery. |
| crates/…/checker.rs | Explains team membership and project grant resolution. |
| crates/…/role_permissions.rs | Maps project roles to project permissions. |
| crates/…/oidc_handler.rs | Shows browser-bound OIDC login and provider administration. |
| crates/…/oidc_service.rs | Shows OIDC identity resolution, Cloud-managed access, and provider revocation. |
| crates/…/oidc_errors.rs | Shows safe OIDC error responses. |
| crates/…/temps_middleware.rs | Shows permission-denial audit attribution. |
| crates/…/handlers.rs | Defines protected audit-log reads. |
| crates/…/proxy.rs | Shows where attack-mode and CAPTCHA checks sit. |
| crates/…/captcha.rs | Defines challenge verification routes. |
| crates/…/README.md | Explains the browser solver and fallback. |
| web/…/OidcRoleMappingsCard.tsx | Shows ordered OIDC role mapping controls. |
| web/…/UsersManagement.tsx | Shows user lifecycle and role controls. |
| web/…/TeamFieldHint.tsx | Shows empty-team versus failed-team messaging. |
| web/…/SecurityPage.tsx | Shows the administrative gate and proxy IP trust setting. |
| web/…/SecuritySettings.tsx | Shows security headers, limits, and IP controls. |