Identity, authentication, and access control
Arcane identity and access control connects a person or system to a user identity, establishes a trusted session, and limits each request to the permissions allowed for that identity. It supports local sign-in, OIDC single sign-on, passkeys, API keys, device authorization, and infrastructure credentials while keeping authentication separate from authorization.
Identity boundary
Arcane treats authentication as the proof of who or what is making a request. Authorization then uses that identity to decide what the caller may do. This separation lets the same permission checks serve browser users, programmatic clients, and remote environment agents.
Authentication inputs
The manager accepts several credential types. A browser user normally presents a bearer token in the Authorization header or a browser token cookie. An API client presents an API key. An environment access token identifies one environment, while an agent token identifies trusted Arcane infrastructure.
The authentication layer resolves a valid credential into a current user or infrastructure actor and an effective permission set. For API keys, it also retains the key identity so authorization can apply the key's kind, owner, expiry, and scope. It records the authentication method when downstream actions need to distinguish an interactive session from a non-interactive credential.
References: backend/…/handler.go• L576-703 backend/…/handler.go• L737-809 backend/…/middleware.go• L976-1078 backend/…/service.go• L993-1067
Authenticated request context
After authentication, Arcane places the user identity, session identity when one exists, authentication method, and effective permissions in the request context. Protected handlers use this shared context instead of parsing credentials again. A missing or invalid permission set becomes deny-all.
The context may represent a human user, an environment-scoped actor, or an agent with infrastructure-level access. An environment token can act only within its environment. An agent token uses a separate infrastructure trust path and does not represent a human user's role. Agent-mediated container updates may also carry the initiating user's identity for activity records without changing the agent's authority.
References: backend/…/handler.go• L601-735 backend/…/handler.go• L812-856 backend/…/middleware.go• L1119-1134
Login methods
Arcane supports several ways to establish a user identity. Each method validates its own proof and then converges on the common session issuer after all required factors succeed.
Local credentials
Local login validates a username or email and a password when local authentication is enabled. An email-like identifier must resolve to one account. Arcane rejects ambiguous email matches and collisions between one account's username and another account's email.
Password validation is a primary factor only. If the account requires passkey MFA, Arcane returns a pending MFA transaction instead of an authenticated session. A completed login then uses the same session model as federated and passkey login.
Password changes follow the active password policy. They keep the current session when possible and revoke the user's other sessions so old credentials cannot continue to provide access.
References: backend/…/service.go• L160-252 backend/…/service.go• L265-313 backend/…/handler.go• L98-165 backend/…/handler.go• L250-275
OIDC federation
OIDC, or OpenID Connect, delegates sign-in to an external identity provider. Arcane can use provider discovery or configured endpoints. It protects the authorization-code round trip with state, a nonce, and a code verifier, then validates the returned identity before it creates or updates the local user account.
The provider subject is the stable link to the Arcane user. Arcane can create a new account, update an existing OIDC account, or merge into a local account when account merging is enabled and the provider supplies a suitable verified email. Provider-managed name and email fields are not changed through the local profile path.
Browser and mobile clients use different redirect handling. Native clients must use an exact match from the configured mobile redirect allowlist. The flow carries the requested destination through state data and accepts it only after the state, expiry, and redirect checks succeed.
OIDC also supports device authorization for clients such as the CLI. Device polling returns a session after the provider grants access, but an account that requires passkey MFA cannot complete this flow because the device client has no WebAuthn assertion path.
After a successful OIDC login, Arcane rebuilds assignments sourced from provider groups. Manual assignments remain separate, so a provider group change does not erase a local access grant.
References: backend/…/service.go• L84-92 backend/…/service.go• L198-271 backend/…/service.go• L446-563 backend/…/service.go• L255-345 backend/…/service.go• L364-471 backend/…/service.go• L531-599 backend/…/handler.go• L159-371 backend/…/module.go• L17-131
Passkeys and MFA
Passkeys use WebAuthn assertions as a passwordless login method or as a second factor. Arcane requires user verification and discoverable credentials for passkey login. A discoverable passkey can identify the user directly. A local or OIDC login can instead pause after the primary factor and require a passkey assertion or a one-use recovery code.
Mobile passkey login adds a short-lived exchange bound to a verifier. The passkey service validates the assertion and creates a one-time transaction. The common authentication service issues the final session only after the client proves possession of the matching verifier. This keeps mobile login on the same session model as browser login.
Passkey enrollment and removal are account-management actions. The first passkey may be enrolled from an active session. Later changes require fresh step-up proof. The account must keep at least one usable authentication method. MFA must be disabled before its last passkey is removed. Disabling MFA revokes the user's other sessions.
Passkey ceremonies and authentication transactions are short-lived server-side records. Step-up grants remain tied to the issuing user and session for their brief lifetime, while recovery codes are stored as one-way values and can be consumed only once.
The main login paths converge after their factors are complete. The following diagram shows the shared outcome.
flowchart LR
Local[Local password] --> Primary[Primary identity proof]
OIDC[OIDC provider] --> Primary
Passkey[Passkey] --> Primary
Mobile[Mobile passkey] --> Exchange[Verifier-bound exchange]
Exchange --> Primary
Primary -->|MFA required| Factor[Passkey or recovery code]
Primary -->|No MFA| Session[Session and tokens]
Factor --> Session
Session --> Request[Authenticated request]
References: backend/…/service.go• L76-185 backend/…/service.go• L297-347 backend/…/service.go• L405-485 backend/…/service.go• L538-755 backend/…/service.go• L772-1025 backend/…/handler.go• L178-288 backend/…/handler.go• L320-470 backend/…/module.go• L12-200 backend/…/model.go• L47-99 backend/…/service_test.go• L70-341
Session lifecycle
A session is the server-side record that binds issued tokens to a user, an authentication source, and an expiry. Access tokens authorize requests for a short period. Refresh tokens extend the session only while the stored session remains active.
Session issuance
Once all required factors succeed, the authentication service creates a session and returns an access token plus a refresh token. Browser flows also receive a separate browser session token in a cookie. All issued tokens point to the same stored session, so downstream authorization has one stable session model even when the initial proof differs.
The access and refresh tokens are signed with Arcane's application signing key. The browser token uses the browser-session signing key and is accepted from the cookie path. Short-lived federated credentials also receive a stored federated session, which gives non-browser integrations the same server-side revocation boundary.
The session records audit data such as its source, user agent, IP address, and MFA method. The server selects this source and carries it through pending MFA and mobile passkey transactions instead of accepting it from the client.
References: backend/…/service.go• L265-312 backend/…/service.go• L880-1023 backend/…/helpers.go• L19-59 backend/…/service.go• L129-136 backend/…/service.go• L30-75
Session continuity and revocation
Every access-token check validates both the signed token and its stored session. Refresh rotates the refresh credential and updates the session. Logout revokes the current session. Users can revoke all other sessions, while password changes revoke all sessions except the current one.
An access token from an older application version can recover through refresh when its session remains valid. A refresh token is checked against the current session and then replaced, so replaying the old refresh token does not extend access. A revoked or expired session cannot be restored by a still-valid signed token because session state is part of the authorization decision.
Changes to user access also clear the related permission or token-verification state after the database change. This keeps role changes, account removal, and credential revocation from waiting for a cache timeout.
Expired and revoked sessions are removed by scheduled cleanup after their retention period.
References: backend/…/service.go• L658-791 backend/…/service.go• L794-877 backend/…/helpers.go• L61-155 backend/…/handler.go• L168-247 backend/…/service.go• L906-920
User accounts
A user account is Arcane's local identity record. It holds the identity data needed for sign-in and display, links an OIDC subject when applicable, tracks password state, and exposes the user's role view to clients.
Account identity
Local accounts use a username and may have an email address. OIDC accounts use the provider subject as the durable external identity link. A user response includes role assignments and effective permissions by environment so the web application can show access without becoming the authority for it.
Profile updates can change local account details and preferences. OIDC-managed identity fields remain controlled by the provider. Users can also manage a presentation-only avatar; it does not grant access. Changes to the user's returned identity data invalidate the local verified-token cache so later requests do not keep stale user state.
OIDC account linking is transactional. This prevents two concurrent merges from attaching one provider subject to different users or from replacing an already-linked subject.
References: backend/…/service.go• L141-194 backend/…/service.go• L386-435 backend/…/service.go• L609-687 backend/…/handler.go• L192-216 backend/…/handler.go• L294-478
Account administration
User administration can create, inspect, update, and delete accounts. These actions are permission-protected and apply privilege ordering: a delegated operator cannot modify or remove a global administrator. The service locks the actor and target while it rechecks effective privilege, so a concurrent role change cannot bypass that boundary. Arcane keeps at least one effective global administrator, so a role change or deletion that would remove the last one is rejected.
Role assignments are managed as a separate administrative action. This keeps account data changes distinct from changes to access rights. Changes to a user's access also invalidate cached token or permission state where needed.
On a new installation, Arcane creates a default administrator and requires a password change. Recovery can restore the administrator role to the existing arcane account only when no effective global administrator remains. An unrelated account is not promoted merely because it uses that username.
References: backend/…/handler.go• L65-139 backend/…/handler.go• L161-245 backend/…/handler.go• L248-282 backend/…/service.go• L206-295 backend/…/service.go• L438-583
Roles and permissions
Arcane uses role-based access control, or RBAC, to turn reusable roles into effective permissions. A role is a named set of known actions. An assignment connects a user to a role and may apply globally or to one environment.
Permission scopes
Global permissions apply to all environments and organization-level actions. Environment-scoped permissions apply only to the named environment. A caller can therefore manage one environment without gaining organization-wide access.
The server owns the permission catalog and exposes a manifest for clients. The catalog defines valid actions and their scope. Clients use the manifest to present choices, but the backend remains the source of truth. Role definitions must use known actions, and a role grant must stay within the authority of the caller at global scope because the role may later be reused at another scope. Unknown permissions are rejected before caller-authority checks, including for trusted administrative callers.
Effective permissions are cached for normal requests, but database-backed resolution remains available for decisions that must use current state. This distinction lets routine authorization stay fast without using a stale cache for privilege-sensitive mutations or durable work.
References: backend/…/handler.go• L87-161 backend/…/handler.go• L234-325 backend/…/service.go• L536-615 backend/…/service.go• L922-975 backend/…/service_test.go• L22-60
Role assignments
Assignments have a source. Manual assignments come from administration. OIDC assignments come from provider claims and are rebuilt during OIDC login. Rebuilding OIDC assignments does not remove manual assignments, so local exceptions can coexist with provider group changes.
Built-in roles provide common access levels such as administrator, editor, no-shell editor, deployer, monitor, and viewer. The server maintains them. Custom roles are available to authorized administrators and must use known permissions. Assignment changes must name existing roles and environments. Role and assignment changes invalidate affected effective-permission caches after the database change. Role edits and deletes lock the users assigned to the role before changing it, then invalidate those users after commit.
The last-global-administrator rule is checked when assignments change. A role edit also accounts for every user assigned to that role, because changing a reusable role can change several users' effective access at once. A custom role with the full permission catalog counts as a global administrator, while an environment-only assignment does not.
References: backend/…/handler.go• L113-205 backend/…/service.go• L62-90 backend/…/service.go• L239-360 backend/…/service.go• L386-490 backend/…/service_test.go• L209-299
OIDC role mappings
An OIDC role mapping connects a provider claim value to a role assignment. On sign-in, Arcane reads the configured groups claim and creates matching OIDC-sourced assignments. A mapping may grant the role globally or for one environment.
Mappings can be managed through the UI or declared by deployment configuration. Configuration-managed mappings are read-only at runtime and are reconciled when the server starts. An unset declaration leaves UI-managed mappings in place, while an explicit empty declaration removes configuration-managed mappings. Manual mappings are not changed. Invalid deployment mappings fail reconciliation instead of silently dropping access rules.
References: backend/…/service.go• L531-599 backend/…/service.go• L716-903 backend/…/handler.go• L374-464 backend/…/module.go• L90-131
API key access
API keys provide non-interactive access to the manager. A scoped key carries its own global or environment-level grants. A personal key carries no independent grants and inherits the owner's current role permissions when it is used. Environment bootstrap keys carry access for their paired environment, while a managed static key serves deployment bootstrap needs. Bootstrap grants are restored when needed during startup, but a user-owned key with no grants remains intentionally without access.
API key validation uses a short-lived in-process validation cache, but expiry is checked on every cache hit and key changes invalidate affected entries after the database change. Durable work resolves the key and its owner again without relying on this authentication cache. A key that is limited to one environment is also limited to that environment when durable permissions are resolved.
The full secret is returned only when a key is created. Later responses contain identifying metadata and grants, not the secret. A caller cannot grant a key permissions beyond the caller's current authority or the owner's role authority. Personal key creation and deletion require an interactive session, so an API key cannot mint or remove another persistent personal credential. Self-service deletion also checks ownership. A key that an environment currently uses for pairing cannot be edited or deleted until it is no longer referenced.
References: backend/…/handler.go• L737-785 backend/…/handler.go• L1050-1087 backend/…/handler.go• L67-151 backend/…/handler.go• L154-236 backend/…/service.go• L67-211 backend/…/service.go• L337-443 backend/…/service.go• L664-761 backend/…/service.go• L852-1080 backend/…/service_test.go• L319-358 backend/…/service.go• L599-685
Authorization enforcement
Authorization is enforced by the backend at the operation boundary. A route declares whether it needs authentication and which permission or administrator level it requires. The request's effective permission set is then checked against the route and, for environment actions, against the target environment.
Request checks
The authorization sequence is:
- Resolve a supported credential into a user or infrastructure actor.
- Resolve the actor's global and environment-scoped permissions.
- Apply the operation's required permission or global-administrator rule.
- Run the handler only when the required scope allows the action.
Permission lookup errors produce a deny-all result. Role definitions must use known permissions. A caller cannot grant a role or assignment permissions beyond the caller's authority at the requested scope. The web application may hide inaccessible routes or settings, but that behavior is only a user-interface aid.
References: backend/…/handler.go• L638-703 backend/…/handler.go• L737-825 backend/…/middleware.go• L1042-1104 backend/…/role.go• L36-99 backend/…/service.go• L922-975
Durable work authorization
Work that continues after the request must not rely only on the permissions resolved during authentication. Before durable work runs, Arcane rechecks that the user still exists and that the API key still belongs to that user, is not expired, and still has the required current permissions. This prevents a queued or delayed action from using access that was revoked after the original request.
For an environment-scoped key, the execution check converts the current grants into that environment's scope. It does not allow a cached global grant or a grant for another environment to widen the delayed action.
References: backend/…/service.go• L599-652 backend/…/service_test.go• L380-445
Remote environment access
Requests for remote environments cross an additional trust boundary. The manager carries the required permission into the remote request path so the same policy applies before work reaches an agent. Environment access tokens receive environment-scoped permissions for one environment, but they do not receive organization-wide permissions.
Agent tokens are different. They identify trusted infrastructure and receive a sudo permission set for infrastructure paths. They are not a substitute for a human user's role. Middleware restricts them to the paths that require agent authentication.
References: backend/…/handler.go• L684-735 backend/…/handler.go• L930-965 backend/…/handler.go• L1114-1142 backend/…/middleware.go• L976-1040 backend/…/middleware.go• L1106-1134
Related pages
- Authentication and authorization flows traces the backend and shared contracts through each sign-in and authorization path.
- Login methods explains local login, OIDC, passkeys, and MFA as user-facing authentication choices.
- Session handling explains token refresh, session records, logout, and revocation.
- Permission administration explains roles, assignments, permission scopes, and OIDC mappings.
- API services explains the API boundary used by authenticated clients.
- Command-line interface explains CLI sign-in and device authorization.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every credential path aligned with the request-context fields used by authorization and with the session source recorded for audit.
- When changing token subjects, required claims, signing keys, or application-version handling, keep access verification, browser cookies, refresh rotation, federated sessions, and recoverable client refresh behavior aligned.
- When adding or changing a permission, update the server catalog, the permission manifest, route checks, built-in role grants, and remote-environment metadata that carries the required permission.
- When changing role or assignment rules, preserve the global-admin safety check, source separation between manual and OIDC assignments, scope-aware grant checks, role-holder locking and invalidation, and post-commit invalidation of cached effective permissions.
- When changing OIDC claims, provider discovery, manual endpoints, redirect allowlists, or mappings, keep ID-token verification, userinfo extraction, account linking, assignment source, device authorization, native-client redirects, and deployment-managed mapping reconciliation aligned.
- When changing passkey or MFA completion, keep the pending transaction tied to the original user, session metadata, authentication source, and final session issuer.
- When changing passkey management, preserve relying-party configuration, first-enrollment rules, session-bound step-up grants, last-credential protection, recovery-code state, ceremony consumption, and session revocation behavior.
- When changing API key kinds or self-service handlers, keep creation, validation-cache invalidation, permission resolution, startup backfill, environment pairing protection, owner checks, and interactive-session restrictions consistent.
- When changing user profile or avatar data returned from authenticated endpoints, preserve OIDC-managed field protection and invalidate any cached user verification that can carry stale identity data.
- When changing account mutation or bootstrap rules, keep actor-vs-target privilege checks, last-admin protection, concurrent role-change handling, and recovery provenance aligned.
- When changing delayed or durable work, keep execution-time user and API-key revalidation aligned with request-time authorization.
- When changing agent-mediated container updates, preserve trusted forwarding of the initiating user's identity so activity records retain user attribution without changing agent authorization.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Access or refresh token has an invalid, expired, or revoked session | The request is rejected and the browser session may be cleared | Verification checks signed claims, the user record, the stored session, and session status |
| Access token has an older application version while the session remains valid | The client gets a recoverable unauthorized response instead of a forced sign-in | Refresh accepts the active session and rotates tokens to the current version |
| A local login identifier matches multiple accounts through username and email | Login is rejected instead of selecting an account by lookup order | Primary-factor authentication rejects ambiguous email matches and cross-account username/email collisions |
| Permission resolution fails | The caller has no effective permissions and protected work is denied | Authorization uses a deny-all permission set on resolution failure |
| A role or assignment change removes the last global administrator | The change is rejected | Role and user mutation paths count effective global administrators |
| A delegated operator tries to change or delete a global administrator | The target account is left unchanged | User mutations compare actor and target privilege and recheck global-admin status in the mutation transaction |
| A role changes while an assigned user's privilege-sensitive mutation is in progress | The mutation cannot use a stale privilege decision | Role edits lock assigned users and user mutations lock actor and target rows before rechecking permissions |
| A role names an unknown permission or an assignment names a missing role or environment | The change is rejected before it creates an unusable access rule | Catalog and assignment validation check every referenced value inside the mutation boundary |
| A caller defines a reusable role with a permission held only in one environment | The role could later grant that permission outside the caller's authority | Role validation requires the caller to hold each role permission at global scope |
| A permission cache remains populated after an access change | A caller may keep old effective permissions until cache expiry | Mutation paths invalidate affected user or API-key entries after commit |
| A delayed action runs after its user or API key loses access | Revoked identity could perform work that was authorized earlier | Execution-time permission resolution rechecks the user, key ownership, expiry, current grants, and environment scope |
| OIDC state, nonce, verifier, or native redirect does not match the active flow | The callback or mobile handoff cannot create a session | The flow checks state values, state expiry, and exact redirect matches |
| OIDC provider discovery or manual endpoint configuration cannot supply verified identity claims | The login fails before account linking | Provider configuration must yield usable authorization, token, and identity verification data |
| An MFA account completes only the primary login factor | No authenticated session is issued | Login returns a pending transaction until a passkey or recovery code succeeds |
| An MFA account uses OIDC device authorization | The device exchange is denied instead of issuing a session | Device authorization does not pretend to complete a WebAuthn factor |
| A caller grants an API key or role a permission beyond its authority | The credential could become a privilege-escalation path | Grant checks compare requested permissions with caller and owner authority |
| A personal API-key request comes from an API key or targets another user's key | The persistent personal credential action is denied | Self-service handlers require a current session and check key ownership |
| A passkey ceremony, MFA transaction, or step-up grant expires or belongs to another session | The requested login or account change is denied | These records are short-lived, single-use where required, and bound to the user and session |
| A user removes the last usable authentication method or the last passkey while MFA is active | The user could lose all ways to sign in | Deletion requires another usable method and blocks removal while MFA depends on it |
| A live environment pairing key is edited or deleted | The paired agent may fail its next authentication | Referenced bootstrap keys are protected until the environment points to another key |
| An OIDC-managed user tries to change provider-managed profile fields locally | The profile change is rejected | The self-profile boundary treats the provider as the owner of those fields |
| A user is deleted or changed while they are the only effective global administrator | The installation could lose its last administrator | The service blocks the mutation until another effective global administrator exists |
Key files
| File | Why to read it |
|---|---|
| backend/…/service.go | Centralizes primary authentication, OIDC account linking, MFA completion, token issuance, refresh, revocation, federated credentials, and cached identity verification. |
| backend/…/handler.go | Shows the public login, logout, refresh, self-profile, password, avatar, and credential-selection boundaries. It also maps bearer, API-key, environment, and agent credentials into request identity. |
| backend/…/helpers.go | Defines the token subjects and required claims that connect signed credentials to users and sessions. |
| backend/…/middleware.go | Shows the manager and agent authentication boundary for standard HTTP requests. |
| backend/…/service.go | Defines session creation, refresh rotation, validation, revocation, and cleanup behavior. |
| backend/…/service.go | Defines passkey login, mobile exchange, MFA, recovery, step-up, and credential management. |
| backend/…/service.go | Defines provider discovery, authorization-code and device flows, redirect validation, and provider identity validation. |
| backend/…/handler.go | Shows the role editor contract, permission manifest, role validation, and user-assignment boundary. |
| backend/…/service.go | Resolves effective and execution-time permissions. It also manages roles, assignments, API-key grants, OIDC mappings, cache invalidation, concurrent role-holder safety, and admin safety checks. |
| backend/…/handler.go | Shows administrative and self-service API-key boundaries, including interactive-session and ownership checks. |
| backend/…/service.go | Defines API key kinds, validation, lifecycle rules, grants, validation-cache invalidation, startup backfill, and environment pairing protection. |
| backend/…/handler.go | Shows user creation and administration boundaries, privilege ordering, password rules, and avatar access. |
| backend/…/service.go | Defines user identity, password handling, OIDC linking, account privilege safety, bootstrap recovery, avatar storage, and the user-facing permission view. |
| backend/…/permissions.go | Defines the canonical permission catalog and built-in role grants. |
| backend/…/permission_set.go | Defines global and environment permission scope and the core allow checks. |
| backend/…/role.go | Defines per-operation permission, global-admin, and sudo enforcement. |