Skip to content
You're reading the docs for the next release. For the current stable release, see the main docs.

Authentication and RBAC

Identity comes from your own identity provider. A client signs in there, exchanges that OIDC token at the control plane for a short-lived Felix token scoped to one tenant, and presents the Felix token to brokers. Brokers check it themselves and enforce tenant-scoped RBAC on every request. The design record, with every endpoint, is docs/auth.md.

The whole flow, end to end:

flowchart LR
    A["Sign in<br/>OIDC token from your IdP"] e1@==> B["Exchange<br/>control plane checks the issuer"]
    B e2@==> C["Felix token<br/>tenant + permissions, signed"]
    C e3@==> D["Connect<br/>broker verifies and enforces"]

    e1@{ animate: true }
    e2@{ animate: true }
    e3@{ animate: true }

Felix never sees your IdP password, and the broker does not ask the control plane about each request: it verifies the signature against the tenant’s published JWKS and reads the permissions out of the token. It fetches the JWKS for every tenant it knows when it starts, renews each one in the background about every 10 minutes, and fetches at once when a token names a key it has not seen, so a newly staged key works straight away.

A control-plane outage does not stop a broker verifying tokens. If a renewal fails, it keeps using the keys it has, for up to 24 hours after the last successful fetch. The cost is that a key retired during the outage keeps verifying on that broker until the control plane is back, or until those 24 hours run out. felix_jwks_oldest_age_seconds shows how stale a broker’s keys are. The details are in Keeping tenant keys current.

New tenants need IdP issuers, signing keys, and initial RBAC before any admin tokens exist. Felix provides a one-time bootstrap mode for operators:

  1. Enable bootstrap on the control plane (disabled by default):
FELIX_BOOTSTRAP_ENABLED=true
FELIX_BOOTSTRAP_BIND_ADDR=127.0.0.1:9095
FELIX_BOOTSTRAP_TOKEN=<random secret>

Two optional hardening layers, independent of each other:

  • Token rotation without an outage. FELIX_BOOTSTRAP_TOKEN_PREVIOUS holds the token being retired; both are accepted (each compared in constant time) while a rolling deploy replaces one with the other. Setting only the previous token fails startup, because it means the rotation removed the wrong half.
  • mTLS on the bootstrap listener. FELIX_BOOTSTRAP_TLS_CERT, FELIX_BOOTSTRAP_TLS_KEY, and FELIX_BOOTSTRAP_TLS_CLIENT_CA (all three, or startup fails rather than coming up half-secured) make the listener terminate TLS itself and refuse, at the handshake, any client without a certificate signed by that CA. An unauthenticated caller never reaches the endpoint, so the token never even gets read.
  1. Call the internal endpoint (bound to the bootstrap address):
POST /internal/bootstrap/tenants/{tenant_id}/initialize
X-Felix-Bootstrap-Token: <secret>
Content-Type: application/json
{
"display_name": "Tenant One",
"idp_issuers": [
{
"issuer": "https://login.microsoftonline.com/<tenant>/v2.0",
"audiences": ["api://felix-controlplane"],
"discovery_url": null,
"jwks_url": null,
"claim_mappings": {
"subject_claim": "sub",
"groups_claim": "groups"
}
}
],
"initial_admin_principals": ["p:alice"]
}
  1. Disable bootstrap after the initial setup.

Initialization is atomic and exactly-once per tenant: the signing keys, issuers, RBAC seed, and the bootstrapped flag commit as one store operation, serialized on the tenant row. Racing the call against itself, including through different control-plane instances behind one load balancer, produces one winner and 409 already_initialized for everyone else, and a failure part-way leaves the tenant retryable rather than half-initialized. The token itself is a static shared secret, valid while bootstrap is enabled. The full threat model, replay rules, rotation procedure, and recovery steps are in docs/security/bootstrap.md.

For a local stack or a CI job, FELIX_BOOTSTRAP_DEV_TOKENS=true makes the bootstrap listener mint a Felix token for any principal of an initialized tenant, with no identity provider:

Terminal window
curl -sS -X POST http://127.0.0.1:9095/internal/bootstrap/tenants/t1/dev-token \
-H 'X-Felix-Bootstrap-Token: change-me' \
-H 'Content-Type: application/json' \
-d '{ "principal": "p:dev" }'

The principal is named as RBAC policies and groupings name it, and the token carries what RBAC grants it, narrowed by requested, resources, permissions and audience exactly as on token exchange. The answer is the exchange’s, refresh token included. The control plane refuses to start with the switch on unless bootstrap is enabled on a loopback FELIX_BOOTSTRAP_BIND_ADDR, and logs a warning that it is on. Anyone holding the bootstrap token can then act as any principal, so never set it on a shared or production control plane.

After bootstrap, admin actions require explicit Felix permissions:

  • IdP issuer admin: tenant.manage:tenant:{tenant_id}, plus tenant.manage:cluster:* to change an existing issuer’s keys, audiences or claim mapping, to register an issuer another tenant already trusts, or to delete one
  • RBAC list: rbac.view:<scoped object>
  • RBAC policy writes: rbac.policy.manage:<scoped object>
  • RBAC assignment writes: rbac.assignment.manage:<scoped object>
  • Namespaces, streams and caches: ns.manage, stream.manage or cache.manage over the object, from a token minted for that tenant; listings are filtered to the caller’s scope
  • Tenant catalog (create, list, delete): tenant.manage:cluster:*
  • Metadata feeds brokers seed from (snapshot, changes): node.view:cluster:*
  • Cluster membership reads: node.view:cluster:*
  • A broker’s view of a shard or of its subscriptions (shard_inspect, subscriptions_list, felixctl inspect): node.view:cluster:*, presented to the broker. Only that exact grant counts; a wildcard such as node.view:* does not reach the cluster
  • Cluster membership writes: node.manage:node:{node_id} or node.manage:cluster:*

The credential is checked before existence, so nothing about what exists can be learned without one: a tenant with no signing keys answers 401, not 404.

Canonical RBAC object formats:

  • tenant:{tenant_id}
  • namespace:{tenant_id}/{namespace}
  • stream:{tenant_id}/{namespace}/{stream_or_*}
  • cache:{tenant_id}/{namespace}/{cache_or_*}
  • cache:{tenant_id}/{namespace}/{cache}/{key} or .../{key_prefix}*: some keys of one cache
  • group:{tenant_id}/{namespace}/{stream_or_*}/{group_or_*}: one consumer group; a * only after other *s
  • cluster:*: the cluster itself, outside the tenant hierarchy
  • node:{node_id}: one broker, also outside it

Write-time protections:

  • tenant:* is rejected
  • non-tenant-scoped wildcards are rejected
  • policy/assignment writes are rejected if target scope is broader than caller scope

This blocks privilege escalation when delegating namespace or stream admins.

felixctl rbac lists, adds and removes policies and groupings over the same API, and checks an object against this grammar before sending it. See felixctl.

cluster:* covers broker membership (which brokers exist, whether they are alive, and whether placement can use them), the tenant catalog, and the metadata feeds. It is isolated from tenant scope in both directions:

flowchart TB
    subgraph tenant["Tenant scope - what a tenant admin can delegate"]
        direction TB
        T["tenant:t1"] --> N["namespace:t1/*"]
        N --> S["stream:t1/ns/*"]
        N --> K["cache:t1/ns/*"]
    end

    subgraph cluster["Cluster scope - operators only"]
        direction TB
        CL["cluster:*<br/>node.view"]
    end

    T x-.-x|"never contains"| CL
    CL x-.-x|"never contains"| T

A permission is only writable when its object already sits inside the writer’s own scope. Because no arrow runs between the two scopes, a tenant admin cannot write themselves cluster:*, and cluster scope cannot read tenant data.

No tenant scope contains cluster:*, and the bootstrap seed does not grant it either. In the other direction, cluster:* contains no tenant object.

Reads require node.view:cluster:*. Writes (register, heartbeat, drain, deregister) require node.manage over the node being changed, held either as node:{node_id} by that broker or as cluster:* by an operator. A node is an RBAC object rather than a field the caller asserts, which is what stops one broker acting for another.

Cluster scope reaches a token only through bootstrap: initialize an operator tenant whose policies grant the cluster actions to a role, assign the operator principal to it, and exchange. The same route gives a broker its node.view:cluster:*.

Felix supports any OIDC-compliant IdP that exposes a JWKS endpoint (via discovery or direct JWKS URL) and uses an allowed upstream OIDC signing algorithm.

Supported upstream OIDC JWT signing algorithms:

  • ES256 and RS256 (the default)
  • RS384, RS512
  • PS256, PS384, PS512

Control plane configuration:

  • YAML: oidc_allowed_algorithms: ["ES256", "RS256"]
  • Env: FELIX_CONTROLPLANE_OIDC_ALLOWED_ALGORITHMS=ES256,RS256,...

Common providers that work out of the box include Microsoft Entra ID, Okta, Auth0, Google, and Apple.

IdP trust is configured per tenant in the control plane store. Each tenant has an allowlist of issuers and audiences, plus optional claim mappings.

The control plane validates:

  • iss matches an allowed issuer for the tenant
  • aud matches one of the configured audiences
  • signature via JWKS (cached with TTL; an unknown kid re-fetches the JWKS at most once per 30 seconds per URL, because it is reachable before the signature is checked)
  • exp with clock skew and iat not in the future

Clients authenticate to the control plane with an upstream OIDC JWT and exchange it for a tenant-scoped Felix token.

POST /v1/tenants/{tenant_id}/token/exchange
Authorization: Bearer <oidc_jwt>
Content-Type: application/json
{
"requested": ["stream.publish", "cache.read"],
"resources": ["namespace:t1/payments", "stream:t1/payments/orders/*"]
}

Response:

{
"felix_token": "<jwt>",
"expires_in": 900,
"token_type": "Bearer"
}

The request body can only narrow the permissions RBAC grants. It cannot widen them. requested keeps the listed actions and resources the listed objects, as a cross product: every kept action on every kept resource.

To give one token different actions on different resources, name action:object pairs in permissions and send requested as an empty list:

{
"requested": [],
"permissions": [
"stream.subscribe:stream:t1/rooms/a",
"stream.publish:stream:t1/rooms/b"
]
}

Each pair is narrowed on its own against the grants with exactly its action, so the token above can read a and write b and nothing else. A pair for an action the principal lacks, or for a resource outside its grants, adds nothing, and a pair broader than a grant keeps the grant as it is. Sending permissions without "requested": [], or with a non-empty requested or resources, is a 400. The empty requested makes a control plane that predates permissions refuse the exchange instead of ignoring the pairs and minting full rights. A refresh keeps the pairs. With the Raft store, pairs are refused with 409 until every control-plane member runs a release that supports them.

Felix tokens are JWTs minted by the control plane and validated by brokers.

  • iss: felix-auth
  • aud: felix-broker for tokens presented to brokers, felix-controlplane for the control plane’s API. Each side refuses the other’s, so a broker cannot replay a client’s token against the API.
  • sub: principal_id (sha256 of iss|sub)
  • tid: tenant id
  • exp, iat
  • perms: effective permissions
  • Algorithm: EdDSA (Ed25519) only; Felix-issued tokens never use RSA. The tenant JWKS publishes the current key and any others still verifying, and verification tries them all. Keys rotate in three steps (stage, activate, retire) through /v1/tenants/{tenant_id}/signing-keys, so brokers learn a key before any token carries it.

Casbin is used with domains for tenant scoping. Policies and groupings are stored per tenant.

Objects:

  • tenant:{tenant_id}
  • namespace:{tenant_id}/{namespace} or namespace:{tenant_id}/*
  • stream:{tenant_id}/{namespace}/{stream} or stream:{tenant_id}/{namespace}/*
  • cache:{tenant_id}/{namespace}/{cache} or cache:{tenant_id}/{namespace}/*
  • cache:{tenant_id}/{namespace}/{cache}/{key} or cache:{tenant_id}/{namespace}/{cache}/{key_prefix}*
  • group:{tenant_id}/{namespace}/{stream}/{group} or group:{tenant_id}/{namespace}/{stream}/*

Actions:

  • rbac.view, rbac.policy.manage, rbac.assignment.manage
  • tenant.manage, ns.manage, stream.manage, stream.create, cache.manage
  • stream.publish, stream.subscribe, stream.trim
  • cache.read, cache.write
  • group.consume, group.manage

stream.trim allows a conditional head trim, which hides a durable stream’s history below an offset. stream.manage also grants it, and so do ns.manage and tenant.manage through the stream.manage they expand to. Publishing or reading does not. The control plane puts stream.trim in a broker token only once the fleet has finalized head_trim, because a broker that predates the action refuses a token naming it.

stream.create, over a stream object, allows creating the streams it covers and nothing else: no reading, listing, changing or deleting them, including the ones its holder made, and no mount, which needs stream.manage. Give it to a component that makes streams for others and should not remove them. It stays off broker tokens. Upgrade every control-plane member before granting it; see Create-only grants.

Consumer-group operations are split in two, over the stream’s object:

  • group.consume: poll, acknowledge, hand back, and list dead letters. stream.subscribe also grants it, so a reader works a group without a new grant.
  • group.manage: redrive or discard a dead letter. stream.manage also grants it; stream.subscribe does not. Both change what every consumer of the group sees, so a principal that may only read cannot do them.

A broker that predates these actions refuses a token carrying either one, so upgrade brokers before writing policies that use them.

Either action can also be granted on one group, group:{tenant_id}/{namespace}/{stream}/{group}. A principal holding a group grant for an action on a stream is scoped to those groups there: its stream grants stop covering that stream’s other groups for that action. Principals with no group grants keep the stream-wide behaviour.

Cache access can be granted on some keys of a cache instead of all of it. A fourth segment names one key, cache:t1/ns/rooms/room1/state, or a prefix ending in *, cache:t1/ns/rooms/room1/*. The prefix is a plain string prefix: user:1* also covers user:10, so end a prefix with a separator when ids share leading characters. The broker checks gets, puts, deletes, conditional writes, counters and key watches against the key, and a prefix watch against its prefix, which only a prefix grant the watch starts with can allow. An exact-key grant never allows a prefix watch. A * anywhere but the end of the key, a bare *, or a wildcard namespace or cache in a key object is refused when the policy is written. A whole-cache grant still covers every key, and a broker that predates key grants refuses requests made with them.

Permission strings embedded in Felix tokens:

stream.publish:stream:t1/payments/orders
cache.read:cache:t1/payments/session
cache.write:cache:t1/payments/session/user:42/*
ns.manage:namespace:t1/payments
tenant.manage:tenant:t1
  • tenant.manage:tenant:{T} implies tenant-scoped namespace/stream/cache permissions.
  • ns.manage:namespace:{T}/{N} implies stream/cache manage + read/write within {N}.

If tenant issuer config sets groups_claim, exchange maps each incoming group to group:<issuer>#<name> (always prefixed, so group:ops and ops stay distinct, and scoped by the token’s issuer, so one IdP cannot claim another’s groups) and adds a transient grouping edge for evaluation:

g, <principal_id>, group:<issuer>#<name>, <tenant>

This enables role assignment by group without per-user policy writes.

Brokers validate Felix tokens (signature + claims) using tenant JWKS published by the control plane and enforce permissions locally using wildcard matching (keyMatch2 semantics).

sequenceDiagram
    participant C as Client
    participant CONTROLPLANE as Control Plane
    participant B as Broker

    C->>CONTROLPLANE: OIDC token exchange
    CONTROLPLANE-->>C: Felix token (JWT)
    C->>B: Connect with tenant_id + Felix token
    B->>B: Verify JWT (iss/aud/exp/tid + signature)
    B->>B: Match action+resource against perms
    B-->>C: Allow or reject operation

A token is bound to a QUIC stream, not a connection: each stream sends its own Auth and every request on it is checked against that token. So one client can carry several users. The Rust client’s Connection::with_identity opens streams under another user’s token over the same connections, and the broker still checks each user’s requests against that user’s grants alone. Each user also gets their own share of the connection’s limits: the subscription cap (FELIX_MAX_SUBSCRIPTIONS_PER_CONN) and the publish byte budget (FELIX_BROKER_PUBLISH_CONN_INFLIGHT_BYTES) apply per tenant and token subject on a connection, under a ceiling for the whole connection (FELIX_MAX_SUBSCRIPTIONS_PER_CONN_TOTAL, FELIX_BROKER_PUBLISH_CONN_TOTAL_INFLIGHT_BYTES, four users’ worth by default). The users share that ceiling, so with the defaults four users at their limits leave a fifth nothing. With FELIX_TLS_CLIENT_CERT_BIND_SUBJECT, a user’s own token is refused on the gateway’s certificate. The gateway exchanges it first at POST /v1/tenants/{tenant_id}/token/delegate, an RFC 8693 token exchange that needs token.delegate:tenant:{tenant_id} and returns the user’s token, no wider and no longer-lived, with act: {"sub": "<gateway principal>"}. The broker binds that token to a certificate issued to its actor. Only a token minted for that gateway can be delegated: the gateway sends its own token as actor_token when it exchanges the user’s sign-in, the user’s token records it in may_act, and /token/delegate refuses a token whose may_act names another caller or nobody. An actor token that is refused makes the exchange a 403 with code actor_refused, which is how the gateway tells its own credential’s problem from a user’s missing permission (forbidden). A broker token stolen from a browser or another gateway therefore cannot be moved onto a gateway’s certificate. Holding token.delegate still means acting as any user whose token was minted for you, so grant it to gateways only. The gateway’s own connections need no broker grant: a holder of token.delegate can exchange for a connection-only broker token, with its own subject and no permissions, by asking for "requested": [], "permissions": []. See docs/auth.md. See Acting for many users.

Revoking a principal ends what its tokens already opened, on every broker. POST /v1/tenants/{tenant_id}/refresh-tokens/revoke revokes the principal named. Removing an RBAC policy or role assignment revokes everyone the rule reached through role assignments, or the whole tenant when it reached an IdP group, whose members the control plane cannot list.

A revocation is a cutoff time. The control plane records it, and brokers read it from a feed they poll on the catalog sync interval (FELIX_CONTROLPLANE_SYNC_INTERVAL_MS, 2 s by default). From then on, a broker token of that principal issued at or before the cutoff is refused, and everything such a token opened ends with the revoked error code: control streams, subscriptions, cache watches and Kafka connections. A delegated token is revoked with its actor too.

sequenceDiagram
    participant A as Admin
    participant CP as Control Plane
    participant B as Broker
    participant C as Client

    A->>CP: Revoke principal, or remove an RBAC rule
    CP->>CP: Record cutoff for the principals it reached
    B->>CP: Poll principal-revocations/changes
    CP-->>B: tenant, principal, revoked_at
    B-->>C: Error with code revoked on each open stream, then close
    C->>CP: Refresh (refused if the principal was cut off)
    C->>B: Auth with a token minted after the cutoff

A gateway that is revoked, or loses token.delegate, can no longer bind or delegate user tokens with a felix-controlplane token minted before that, even one that has not expired: /token/exchange (with actor_token) and /token/delegate check it against current RBAC and its revocations, and answer actor_refused. Users’ refresh chains bound to the gateway end only when RBAC no longer grants it token.delegate, so an RBAC edit that merely reaches the gateway does not log its users out.

Revocation fails open on a broker that cannot reach the feed. Until a poll succeeds again, a new session with a revoked token is accepted until the token expires (at most one access TTL, 900 s by default, after the revocation), and a stream already open keeps running. The broker logs a warning, and time() - felix_revocation_feed_last_success_seconds shows how long it has been; see Observability. The broker does not refuse new streams meanwhile, so a control-plane outage stays out of the data path. Cutoffs and token issue times come from the control-plane members’ clocks. Cutoffs are read on the Raft leader, so the only window is clock skew between members: keep those clocks in sync.

Revocation ends sessions rather than narrowing them in place. A client whose rights were only reduced gets a token minted under the current rules from its next refresh and opens its streams again. Tokens for the control plane’s own API are not revoked; they expire with the access TTL. See docs/auth.md.

A lease is a cache key that one client holds at a time: it takes the key with a conditional write, keeps it by rewriting it before its TTL runs out, and loses it when the entry expires or another write wins. The client whose write made the current version is the holder. A lease token is a short-lived broker token that a broker hands the holder when its write wins. It grants only what the caller’s lease templates name for that key.

Lease tokens are for nodes that share one identity, such as the workers of a scheduler. Without them, any node that may write one workload’s output may write every workload’s output. With them, a node’s own token holds only the lease cache and the templates, so it cannot write a workload’s output without holding that workload’s lease. That stops a stale or slow node from writing after another node took over, and taking a lease is visible to its holder. A compromised node that can write the lease cache can still take a lease, but it can write only for the leases it takes, and their holders notice.

To use them:

  1. Give every broker the same key file:

    Terminal window
    openssl rand -base64 32 > lease-keys
    export FELIX_LEASE_TOKEN_KEY_FILE="$PWD/lease-keys"
  2. Grant the nodes the lease cache and a template for the outputs. The {leases} slot stands for the key of cache acme/prod/leases:

    Terminal window
    felixctl rbac policy add role:node cache:acme/prod/leases cache.write
    felixctl rbac policy add role:node cache:acme/prod/leases cache.read
    felixctl rbac policy add role:node 'stream:acme/prod/wl.{leases}.out' stream.publish
  3. Claim the lease with a conditional put that asks for a token, publish with the token, and renew at the version you hold before the TTL runs out. Each renewal returns a fresh token. See Leases and lease tokens for the Rust code.

sequenceDiagram
    participant N as Node
    participant L as Owner of the lease key
    participant O as Broker for wl.w7.out
    N->>L: cache_put_if leases/w7, absent, ttl 30s, lease_token
    L->>L: templates name cache leases? key valid? then write
    L-->>N: applied, version 1, lease token (exp = now + 30s)
    N->>O: Auth with the lease token, publish to wl.w7.out
    O->>O: verify with the lease key, check perms
    O-->>N: ok
    N->>L: cache_put_if leases/w7, version 1, lease_token
    L-->>N: applied, version 2, fresh lease token
    Note over N,O: the node stops renewing, or another write wins
    O-->>N: exp passes: the stream ends with code revoked

Winning the write is the holder check: only the write that made the newest version gets a token, so a node that lost its lease fails to renew and gets nothing. The broker that owns the key mints the token with the shared key, without asking the control plane, so a lease can be claimed while the control plane is down. Grants still come only from RBAC: a broker mints only what the caller’s own token’s templates name, and refuses before writing when the caller holds none, uses a lease or delegated token, or names a key that cannot be part of a stream or key name.

The token lasts as long as the lease entry, but no longer than the caller’s own token or FELIX_LEASE_TOKEN_MAX_TTL_SECONDS (300 s by default). Unlike other tokens, a lease token’s open streams end at its expiry, so a node cannot keep writing over a stream it opened before it lost the lease. Revoking the caller’s principal also revokes its lease tokens. Each mint is logged at info without the token, and counted in felix_lease_tokens_issued_total.

The lease key is a signing key for every tenant, held by every broker, so protect the file. Brokers accept only tokens shaped like the ones they mint: short-lived, with exact stream or cache key data grants and nothing wider. A principal that can write the lease cache can take a live lease, by writing at the key’s current version or by deleting the entry and claiming it; the holder notices when its next renewal fails. Every client can ask for a lease token. See docs/auth.md for the template grammar, key rotation and the wire details.