Skip to content

Protect applications with Access

Access places organization identity and reusable authorization policy in front of selected Worker hostnames. An application is a protection rule for one existing Worker; it does not deploy, copy, or run the Worker. Unprotected Workers remain public.

Protection also applies to the Worker’s custom domains. The login callback returns to the verified hostname where the browser started; each hostname has its own host-only session cookie.

The curated photo example demonstrates the intended split:

  • photo-studio requires an allowed organization user or a scoped service token.
  • photo-gallery remains public.

Protect a Worker

  1. Open the organization in the tenant console.
  2. Select Networking → Security → Access → Workers, then your Worker.
  3. In Access, select Require sign-in. Choose reusable groups based on organization roles and/or member email addresses. You can create a group here without leaving setup.
  4. Review the allowed groups and session length, then select Enable Access. The initial allow policy is saved with the application before ingress is published. Cancelling does not activate protection.

Use Security → Access → Groups and Service tokens to manage shared resources. Creation opens a focused dialog. Service tokens list their allowed Workers by name; a new secret is shown only once. Removing a group, deleting a policy, disabling Access, or revoking a token requires confirming the named target. The namespace comes from Identity’s authorized organization record; the browser cannot supply or override it.

Select Edit beside a group to change its name, roles, or named user emails. The group keeps its identity and every policy referencing it uses the updated membership rules. Existing browser sessions are checked against the current groups and policies on subsequent requests; a removed match no longer grants access. These edits do not consume another group quota slot.

Organization Worker Access inventory

Browser users with no matching allow policy are denied. Scoped service tokens are authorized separately. Policies are evaluated in displayed precedence order; the first matching allow or block decision wins. Removing application protection republishes ingress and makes the Worker public immediately. It does not delete Worker code or data.

Browser requests without a valid application session are redirected to the installation’s Access sign-in page. A successful organization login and policy decision produces a one-time callback code, followed by a host-only, HttpOnly CF_Authorization cookie on the protected Worker hostname. Access binds that callback to a short-lived, host-only browser-state cookie so another browser cannot reuse the login continuation. If a continuation can no longer be completed, choose Continue to application to start a fresh sign-in and return to the requested page. Access does not grant a session from a rejected continuation. Access then forwards the verified assertion and authenticated user email to the Worker as:

Organization sign-in for a protected application

Cf-Access-Jwt-Assertion
Cf-Access-Authenticated-User-Email

HAProxy strips caller-supplied copies of those headers. The current assertion uses an installation-specific HS256 signing key; there is not yet a public JWKS endpoint or external identity-provider login.

Call a protected Worker from automation

Under Service tokens, create a credential and scope it to one or more Access applications. The secret is shown only once. Set PROTECTED_WORKER_URL to the URL copied from the Worker overview, then send both headers:

curl -sS "$PROTECTED_WORKER_URL" \
  -H 'CF-Access-Client-Id: access-…' \
  -H 'CF-Access-Client-Secret: …'

Select Edit beside a service token to rename it or change its allowed Workers. Its client ID and secret remain unchanged, and the secret is not shown again. Scope changes apply to subsequent requests. Revoke a token from the same page to stop subsequent requests; a revoked token cannot be edited or restored.

Use WebSockets

Protected Workers support WebSocket upgrades through the same Access policy. Browser applications sign in over HTTPS first, then open a same-origin wss:// connection. Access validates the application cookie before accepting the upgrade; unauthenticated upgrades receive HTTP 401 rather than a login page. Automation can use the service-token headers above for its handshake. The Worker receives the same verified identity headers as an HTTP request, not the Access cookie or service-token secret.

Text and binary messages and negotiated subprotocols are forwarded in both directions. Browser Origin must match the protected hostname. Connections revalidate their original credentials every 30 seconds and close when those credentials expire, a service token loses access, or a browser no longer matches an allow policy. Group and policy changes take effect at that recheck, not by replaying previously accepted messages.

The Access gateway admits up to 32 concurrent protected connections per organization and 128 overall, with a 1 MiB limit per message. These are gateway safety bounds, not Worker allocations. Connections renew after at most 30 minutes and may also close during deployments or network interruptions. Applications should reconnect with backoff and reload durable state after reconnecting; transport recovery does not imply replaying application mutations.

Inspect access activity and limits

Security → Events, with Access selected as the source, records configuration changes and allowed or denied principals without storing credential secrets. Access exports low-cardinality decision, proxy outcome, and upstream-response-header latency metrics into the platform telemetry pipeline. Systemd journal entries are collected with the other platform services. Protected WebSocket metrics separate handshake latency from connection lifetime and report active connections per organization and application. Message bodies are not captured.

Usage & limits groups the following authoritative holdings under Access:

  • protected applications;
  • reusable groups;
  • active service tokens.

The Access service reserves quota before growth and fails closed if quota enforcement is unavailable. Removing protection, deleting an unused group, or revoking a token reconciles the corresponding holding. A group referenced by a policy cannot be deleted until the policy is removed.

Understand the boundary

HAProxy asks Access for the current protection snapshot whenever routes are reconciled. A protected request goes to the Access gateway, then returns through a private HAProxy listener guarded by a platform proxy token before reaching the shared workerd pool. A public Worker continues directly from HAProxy to that pool. Access is application-level authentication and authorization; it does not change the V8 isolate boundary or provide VM-grade isolation.

See the Access request flow and Organizations and access for the surrounding identity and tenant model.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close