Federated access and edge connectivity
Arcane joins external workload identity with access to remote edge environments. A trusted workload exchanges an OIDC token for a short-lived Arcane token. An edge agent then keeps a protected path to a private environment so Arcane can apply the same identity and permission rules to direct and tunneled traffic.
System boundary
Federated access and edge connectivity address two related trust boundaries. Federated access identifies a workload that runs outside Arcane. Edge connectivity reaches an environment that runs behind a firewall or on a private network.
The manager remains the policy point for both paths. It validates the caller, maps the caller to Arcane permissions, and only then sends work to the target environment. This keeps local requests, direct remote requests, and edge requests under one access contract.
Federated identity trust
Federated identity uses a configured trust rule to map an external OIDC subject to an Arcane service identity. The rule names the HTTPS issuer and accepted audiences. It also limits which subject can use the rule and grants a role with an optional environment scope.
The rule creates a dedicated service account and a matching role assignment. A successful exchange issues a short-lived bearer token for that account. The account's role and environment scope govern later API and edge requests. Deleting the rule also removes its service identity. See Federated credentials and exchange for the credential and exchange lifecycle.
| Trust input | Purpose |
|---|---|
| Issuer | Names the HTTPS OIDC provider that signs the subject token. |
| Audience | Limits which external tokens can use the rule. Duplicate or empty values do not widen the trust set. |
| Subject claim and match | Identifies the workload. The match is exact by default or uses a bounded glob pattern. |
| Role and environment | Defines what the resulting Arcane identity can do and where it can act. The creator cannot grant a role or environment scope beyond their own permissions. |
| Enabled and expiry state | Controls whether the rule can issue tokens now. |
| Token lifetime | Sets the bounded lifetime of each Arcane token. |
References: backend/…/helpers.go• L21-47 backend/…/helpers.go• L135-154 backend/…/service.go• L104-162 backend/…/service.go• L266-290
Token exchange
The token exchange is an RFC 8693 form endpoint at /api/auth/federated/token. A workload presents a JWT or OIDC ID token. Arcane discovers the issuer's signing keys, verifies the token, checks the audience and subject rule, rejects replay, and returns an Arcane access token. Invalid requests and invalid grants use the exchange error shape rather than the normal API response shape.
The exchange follows this trust sequence:
sequenceDiagram
participant W as External workload
participant A as Arcane manager
participant O as OIDC issuer
participant P as Arcane policy
W->>A: Subject token exchange request
A->>O: Discover issuer and signing keys
O-->>A: OIDC metadata and keys
A->>A: Verify token and reject replay
A->>P: Match issuer, audience, and subject
P-->>A: Service identity and role scope
A-->>W: Short-lived bearer access token
Disabling a trust rule stops new exchanges and revokes active sessions issued by that rule. Changing its role or environment scope refreshes the service identity's effective access and invalidates cached permission state.
References: backend/…/handler.go• L128-148 backend/…/service.go• L293-469 backend/…/service.go• L471-528 backend/…/service.go• L208-264
Edge connection trust
An edge environment is reached through an edge agent instead of a public manager-to-environment URL. The manager resolves the agent token to an environment during registration. This binds the live connection to one expected environment before it can serve requests.
Arcane supports persistent gRPC and WebSocket tunnels. Poll mode adds an HTTP control path that tells the agent when a data tunnel is needed. Optional or required mutual TLS adds a certificate identity check to token authentication. Arcane can enroll and renew a per-environment client certificate when managed certificates are enabled.
The manager accepts a connection only after registration identifies the agent and the token resolves to an enabled environment. When a certificate is used, its identity must match that environment. Arcane records the accepted connection as live environment state.
References: backend/…/server.go• L119-179 backend/…/server.go• L182-259 backend/…/server.go• L261-295 backend/…/tls.go• L624-674
Tunnel session
One tunnel session carries requests, responses, streamed bodies, WebSocket frames, heartbeats, and agent events. The manager keeps one active session for an environment. A reconnect from the same agent can replace the old session, while a second live agent is rejected.
Heartbeats keep the session live. Their failure closes the connection and starts reconnect behavior. The manager updates environment status when the session changes, and stale-session cleanup prevents an old connection from remaining available. Agent events can flow back to the manager for storage or notification dispatch.
flowchart LR
Agent[Edge agent] -->|register and heartbeat| Tunnel[Active tunnel]
Manager[Arcane manager] -->|requests and stream starts| Tunnel
Tunnel -->|responses, frames, events| Manager
Manager --> State[Environment runtime state]
State --> UI[Status and access decisions]
References: backend/…/types.go• L199-220 backend/…/client.go• L399-510 backend/…/client.go• L512-599 backend/…/client_test.go• L196-308
Transport selection
The agent selects the configured tunnel transport and reconnects after failure with increasing delay. Automatic mode tries gRPC first and falls back to WebSocket when both paths are available. After repeated gRPC failures, a recent successful WebSocket fallback can remain preferred for a limited period. An established gRPC session that later closes is treated as a session loss rather than an immediate transport failure.
Poll mode separates control from data. The agent checks the manager's demand state and opens a managed data tunnel when the state is required or active. It closes the tunnel when the state becomes idle. Failed control checks also back off, while a successful check restores the manager's advertised poll interval.
| Mode | Control or data path | Main use |
|---|---|---|
grpc | Persistent bidirectional gRPC stream | Direct managed tunnel where HTTP/2 is available. |
websocket | Persistent WebSocket tunnel | Managed tunnel through WebSocket-capable network paths. |
auto | gRPC with WebSocket fallback | Negotiation across common network paths. |
poll | HTTP demand checks with an on-demand tunnel | Environments that need the manager to control when the data path is open. |
All transports present the same agent credential set during control or tunnel setup. This keeps token authentication consistent when the selected transport changes.
References: backend/…/transport.go• L9-81 backend/…/client.go• L114-161 backend/…/client.go• L205-289 backend/…/client_transport_grpc.go• L25-98 backend/…/client_transport_poll.go• L26-111
Edge mutual TLS
Edge mutual TLS adds a second identity check to the agent token. The manager can use a configured certificate authority or create a managed authority. It then issues a client certificate whose URI identity names the environment.
The agent enrolls its certificate over HTTPS with the agent token. It checks the certificate and key before use and renews the pair before expiry. Optional mode can continue with token authentication when enrollment or certificate loading fails. Required mode treats that failure as a startup or connection error.
References: backend/…/tls.go• L65-89 backend/…/tls.go• L305-413 backend/…/tls.go• L415-485 backend/…/tls.go• L966-1039
Authenticated environment routing
Environment routing presents local and remote resources through the same environment-scoped API shape. Arcane resolves the environment, authenticates the caller, checks the required permission, and only then selects a direct remote URL or an edge tunnel.
The request path has two broad outcomes:
- Manager-owned paths continue through the manager.
- Resource paths for a remote environment go to the direct remote API or to the edge agent.
Manager-owned paths stay local because their records and policy belong to the manager. Edge resource paths do not use a direct edge:// URL. If no tunnel is active, Arcane marks the environment as needed and waits briefly for an agent to connect. If the tunnel does not appear, the request fails as unavailable rather than bypassing the edge boundary.
flowchart TD
Request[Authenticated API request] --> Env[Resolve environment]
Env --> Policy[Check permission for target environment]
Policy -->|manager-owned path| Local[Handle at manager]
Policy -->|remote resource path| Kind{Environment type}
Kind -->|direct remote| HTTP[Proxy HTTP to remote API]
Kind -->|edge| Live{Active tunnel?}
Live -->|yes| Tunnel[Proxy through edge tunnel]
Live -->|no| Demand[Request tunnel and wait]
Demand -->|connected| Tunnel
Demand -->|not connected| Fail[Return edge unavailable]
The manager forwards the target environment's access credential through the selected remote path. The agent uses that credential to call its local API. The browser or client session stays outside the agent's trust boundary.
Edge command routing makes this boundary explicit. The edge command catalog maps approved HTTP and streaming paths to command names and exposes only non-local commands for agent capability checks. Path matching ignores query strings and supports environment and resource identifiers, so tunnel dispatch uses one shared route contract. See API transport and webhooks for related API transport behavior.
References: backend/…/environment_middleware.go• L115-190 backend/…/environment_middleware.go• L208-275 backend/…/environment_middleware.go• L381-418 backend/…/environment_proxy.go• L129-240 backend/…/environment_proxy.go• L296-333 backend/…/commands.go• L241-284
WebSocket proxying
WebSocket proxying carries live resource streams and interactive sessions through an edge tunnel. The manager applies the same authentication and permission checks used for HTTP requests. It then opens a matching stream on the agent and copies text or binary frames in both directions.
The manager validates the browser origin before accepting the upgrade. It also closes the stream when the client, agent, or tunnel stops responding. The agent connects to the local WebSocket endpoint with the agent credential and removes browser-only handshake headers. This keeps terminal, log, and statistics traffic live without exposing the edge API to the browser.
sequenceDiagram
participant B as Browser or client
participant M as Arcane manager
participant A as Edge agent
participant R as Local resource API
B->>M: Authenticated WebSocket upgrade
M->>M: Check origin and environment permission
M->>A: Open stream through active tunnel
A->>R: Local WebSocket upgrade
B<<->>M: Client WebSocket frames
M<<->>A: Tunnel stream frames
A<<->>R: Local resource frames
HTTP proxying uses the same tunnel for ordinary responses and streamed bodies. The shared tunnel message contract keeps request IDs, response status, stream data, close signals, and WebSocket frame types aligned across gRPC and WebSocket transport.
References: backend/…/client.go• L544-599 backend/…/client.go• L839-879 backend/…/client.go• L931-992 backend/…/client.go• L1038-1157 backend/…/client_test.go• L1189-1343
Runtime connectivity state
Arcane separates stored environment data from live edge state. The manager stores the last known connection result. The active tunnel and poll registries provide current connection, heartbeat, transport, session, security, and capability data.
The resulting states have distinct meanings:
| State | Meaning |
|---|---|
| Online | A live tunnel serves the environment now. |
| Standby | Poll check-ins are fresh, but no data tunnel is open because no request needs one. |
| Offline | No live tunnel or fresh poll check-in exists. |
| Pending | The environment has not completed its normal setup. |
Connection changes update environment status and wake status watchers. A reconnect can replace a session without creating a false offline transition when another valid session is already active.
References: backend/…/environment_health.go• L334-419 backend/…/poll_control.go• L61-109 backend/…/poll_control.go• L157-191 backend/…/transport.go• L84-117 backend/…/edge_bootstrap.go• L216-250
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the RFC 8693 form names, response names, and error names aligned with the federated exchange handler and shared federated types.
- Keep HTTPS issuer validation, audience normalization, subject matching, role grants, environment scope, and token lifetime rules aligned across credential management and exchange.
- Keep federated service-account creation, role assignment, deletion, and permission invalidation aligned with credential lifecycle changes.
- Keep credential disable and role or environment changes aligned with service-account permission invalidation and active-session revocation.
- Keep the common agent credential set aligned across gRPC metadata, WebSocket headers, and poll requests.
- Keep automatic transport fallback distinct from recovery after an established gRPC session closes.
- Keep poll demand states aligned with the lifetime of the on-demand data tunnel.
- Keep the tunnel message contract aligned across gRPC encoding, WebSocket encoding, HTTP streaming, and WebSocket frames.
- Keep the edge command catalog, advertised command names, route validation, and stream markers aligned when edge API paths change.
- Keep edge mTLS enrollment, certificate renewal, URI identity checks, security-state reporting, and deployment assets aligned when certificate rules change.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| External token has an unknown issuer, bad signature, wrong audience, or unmatched subject | Arcane rejects the exchange and issues no Arcane token | OIDC discovery, signature verification, and trust-rule matching before token issue |
| External subject token is replayed | A second exchange is rejected | Issuer-scoped replay record until the subject token expires |
| Federated credential is disabled or expired | New exchanges fail. Disabled credentials also lose active session access | Credential state checks, session revocation, and token-cache invalidation |
| Federated role or environment scope exceeds the caller's grant | Credential creation or update is rejected | Validate the grant against the caller's resolved permissions |
| Edge token does not resolve to an enabled edge environment | Tunnel registration is rejected | Environment-scoped token resolution |
| Agent certificate identity does not match the token's environment | The tunnel is rejected before it can serve requests | Verified certificate URI identity check |
| gRPC setup reaches the manager but registration receives no response | The agent abandons that attempt and may fall back only in auto mode | Registration timeout and transport-specific fallback rules |
| Poll control reports an idle tunnel | The on-demand data tunnel closes | Poll state controls session start and stop |
| Edge tunnel has no active heartbeat | Requests cannot reach the edge resource | Heartbeat failure closes the session and stale-session cleanup removes it |
| Edge request has no matching method, path, or stream route | The manager cannot resolve or validate an edge command | Keep the route catalog and advertised command set aligned with supported edge endpoints |
| Proxied path has no permission mapping | The request is denied instead of reaching the agent | Default-deny permission matcher |
| Browser origin is not accepted for a proxied WebSocket | The live stream or terminal does not open | Shared origin validation before upgrade |
| Local WebSocket dial receives browser handshake or browser auth headers | The local upgrade can fail or use the wrong identity | Remove browser-only headers and set the agent credential for the local dial |
Key files
| File | Why to read it |
|---|---|
| backend/…/handler.go | Shows the federated credential API boundary and the exchange error contract. |
| backend/…/helpers.go | Shows trust-rule validation and the limits on subject matching, role scope, and token lifetime. |
| backend/…/service.go | Shows how a trust rule becomes a service account, how changes invalidate access, and how an external OIDC token becomes a short-lived Arcane token. |
| backend/…/client.go | Shows agent registration, reconnect behavior, heartbeats, local request handling, and WebSocket streams. |
| backend/…/commands.go | Defines the approved edge HTTP and streaming command routes and their capability names. |
| backend/…/client_transport_grpc.go | Shows the gRPC tunnel connection and registration boundary. |
| backend/…/client_transport_poll.go | Shows poll demand and on-demand tunnel lifetime. |
| backend/…/transport.go | Defines transport selection and live tunnel state reporting. |
| backend/…/tls.go | Shows edge certificate enrollment, renewal, and environment identity checks. |
| backend/…/types.go | Defines the shared tunnel state and transport-neutral message model. |
| backend/…/ws_proxy.go | Shows the manager-side WebSocket bridge and stream lifetime rules. |
| backend/…/environment_middleware.go | Shows the common authentication, permission, and local-versus-remote routing boundary. |
| backend/…/tunnel.proto | Defines the shared gRPC tunnel contract. |
| backend/…/client_test.go | Demonstrates end-to-end HTTP, WebSocket, gRPC, fallback, reconnect, and certificate-related connection guarantees. |
| backend/…/edge_bootstrap.go | Shows how the manager attaches edge routes, status updates, and event handling to the application. |