How clients authenticate

How clients authenticate

A client sends a short-lived token, usually obtained with an API key, that lists what it may do.

When Nova checks credentials, every request carries a token: a short-lived JWT in the Authorization header. The token's scope lists the operations it allows, on which buckets and streams. Most clients hold an API key and trade it for tokens through the exchange. The SDKs and the CLI make that trade for you.

These are the claims of a token for the stream orders/eu in the bucket apps:

A token's claims
{
  "exp": 1795371280,
  "iat": 1795370980,
  "scope": "nova:append:apps:orders%2Feu nova:read:apps:orders%2Feu",
  "sub": "ce97b839f9cae1f3"
}

scope allows appends and reads on that one stream. sub is the ID of the API key the token came from. It shows up in Nova's logs and grants nothing. exp is when the token expires, five minutes after iat here. API keys and tokens explains the scope grammar and the exchange.

What a client sends

Each client takes one credential. The operator picks what the cluster accepts, and that sets what you send:

The cluster checksYour client sendsUse when
NothingNo credentialA local cluster, or a network you trust
TokensAn API key, which the SDK trades for tokensA backend service. This is the usual choice
TokensA token your own issuer signedYour identity provider already issues tokens
TokensA short-lived token from your backendA browser app
A username and passwordThe operator's login, which allows every operationA test cluster with one trusted user
Client certificatesA TLS certificate, which allows every operationServices inside your network, set up by your operator

The SDK names each credential in both languages: APIKey / apiKey, Bearer / bearer for a fixed token, BearerFunc / bearerFunc for a token your code fetches before each call, and BasicAuth / basicAuth for the operator's admin login. Authenticate with an SDK shows the code.

Keep the API key on a server. Without an explicit credential, the SDKs and the CLI read it from NOVA_API_KEY. Both check the key's checksum before any call, so a mistyped key fails at once, without a network round trip.

How the SDK uses an API key

The SDK exchanges the key the first time a call needs a token. A call on a stream gets a token for that one stream. A bucket operation gets a token for the bucket, and listing buckets asks for the list permission it needs. The token gets every permission the key has on that resource.

Each client caches up to 64 of these tokens and renews each one 30 seconds before it expires. Calls that need the same token at the same time share one exchange. Two clients never share a cache, even when they share a key.

You can ask for one explicit scope instead, and every call then uses the same token. You can also send the exchange to an endpoint of your own that speaks the same JSON, such as a service that signs tokens for your users. When the SDK asks it for a token for one stream, the endpoint must return the scope it granted, or the SDK refuses the token.

When a token expires

Every token must carry exp, and Nova checks it on every call. A token from the exchange lasts 15 minutes unless you ask for another lifetime, and at most 1 hour.

A long-lived connection, such as a producer session or a subscription, ends when its token expires. The SDK reconnects with a fresh token. It sends again the batches that have no acknowledgement yet, and the subscription continues where it stopped, without spending its retry budget. Over HTTP, a subscription ends with an auth-expired event, and you reconnect from the last event's ID; browser apps shows how.

When Nova refuses a request

StatusgRPC codeWhen
401UnauthenticatedNo token, a malformed one, or an expired one
403PermissionDeniedThe token is valid, but its scope does not allow the operation

Over HTTP, the body says why. These are a request with no token, and a trim with a token that only appends and reads:

Refusal bodies over HTTP
401 {"error":"auth: no credential"}
403 {"error":"dataplane: no grant covers trim on apps/orders/eu"}

Nova checks the scope before it looks up the stream. A 403 therefore never tells a caller whether a stream exists. Send a fresh token after a 401. A 403 stays the same until the credential gets that permission. Every other status is in API errors.

Your operator chooses what the cluster checks and holds the signing keys; see server authentication.

See also

On this page