Stale JWKS Recovery: receivers refusing canopy-identity tokens

Overview

Every canopy service validates canopy-identity tokens against the keys canopy-security publishes at {IDENTITY_INTERNAL_URL}/jwks (Security › The identity receiver). A receiver refreshes that set every 300 s, refetches on a kid it does not hold at most once per 30 s, and fails closed once the set is 720 s stale (crates/canopy-auth/src/key_cache.rs). canopy-security rotates its own signing keys and publishes each one 60 s before it signs (Security Operations › canopy-identity signing keys). A sender whose token a receiver refuses re-mints and resends once (send_with_retry).

So a key rotation, a canopy-security restart and a brief outage heal on their own. Refusals that persist across services have one of the causes below, and the receivers' logs name which.

Which failure is this?

Answer What it means First check

503 keys_unavailable from many services

The receivers hold no trustworthy key set: canopy-security, or its JWKS, has been unreachable from them past the 720 s stale bound, or a first fetch is failing.

canopy-security’s health and its JWKS (keys_unavailable: the key set).

401 token_rejected from many services at once

Every receiver refuses the tokens it is sent; the log names the rule.

The receivers' log line (Read the logs first).

401 token_rejected from one service only

The token is addressed to another service, or its client has no edge to this one: a defect in the caller, not a key problem.

The log’s rule.

403 with a code (required_role_missing, actor_not_allowed, …)

The token is valid; the route’s admission refused the caller.

Security › Admission.

The worker portal shows the symptom as panels in their error or empty state; e2e specs that read program data fail, while composition-only pages that make no upstream call still pass.

Read the logs first

cargo xtask dev logs canopy-persons --tail 200 --no-follow | grep "canopy-identity"

A receiver logs canopy-identity bearer refused with its code and the validator’s rule for a rejected token, and canopy-identity request refused with its code for any other refusal, never the token (crates/canopy-auth/src/identity_receiver/layer.rs). The rule names the cause (Rejection, crates/canopy-auth/src/identity_token.rs):

Rule Cause and fix

the token’s iss is not the issuer

The issuer identifier moved: canopy-web’s public origin changed (on the devstack, a dev start, reload or restart that sampled a new ingress port), and the receiver, or the token’s minter, still holds the old IDENTITY_ISSUER. Recreate every service on the new value: on the devstack cargo xtask dev reload, in a deployment a roll of every service. Senders then mint under the new issuer, and canopy-cli asks for canopy login again.

the token’s kid names no published key

A refetch found no such key: it was revoked (canopy-web’s /admin/security/keys lists the revocations), or the token was signed by an issuer this receiver does not trust. A replica whose own key was revoked keeps signing with it until it is restarted (Security Operations › canopy-identity signing keys).

the token has expired, the token was issued in the future, the token is not yet valid

The clocks of canopy-security and the receiver disagree by more than the 60 s leeway, which receivers judge on the wall clock. Fix the hosts' time synchronization.

the token’s aud is not this receiver

The caller sent another service’s token: a defect in the caller.

the token’s current actor may not delegate to this receiver, the token’s client holds no system edge to this receiver

The compiled call graph has no such edge: a defect in the caller, or services built from different commits. cargo xtask call-graph check holds the graph to the code.

keys_unavailable: the key set

  1. Is canopy-security up? cargo xtask dev status, then its /readyz (Deployment Guide › Health). Its identity_key check reports whether a key can sign and publication is healthy; pending for the first minute after boot is the first key’s 60 s publish lead.

  2. Does its JWKS answer? From inside the network, GET http://canopy-security:8012/identity/jwks on the devstack (the receivers' IDENTITY_INTERNAL_URL plus /jwks). An empty keys array verifies nothing.

  3. Recovery. Once canopy-security answers, each receiver’s refresher fetches at its next 30 s tick; nothing needs a restart.

Fix

On the devstack, drive restarts through xtask, never raw docker compose restart <service> (Why not docker compose restart <service>):

cargo xtask dev reload     # recreates every service on the current issuer and keys, in dependency order
cargo xtask seed           # if you need fresh fixtures afterward
cargo xtask e2e            # full E2E run (let xtask refresh; don't pass --no-refresh)
NOTE

Prefer cargo xtask dev reload over cargo xtask dev refresh for this symptom. refresh auto-detects changes by content hash and may report "up to date" without recreating services (the #609 SHA-gap). reload forces it.

Senders

A sender whose cached token a receiver refuses with a Bearer challenge naming no error or invalid_token drops that target’s token and resends once with a fresh one; a step-up 401 or a route’s own 401 is returned as it came (refuses_the_bearer, crates/canopy-auth/src/identity_call.rs). A 401 that persists after the retry therefore means the receiver refuses fresh tokens too: a receiver-side cause above, not a stale sender. canopy-cli’s canopy token <SERVICE> answers LoginRequired once its stored session names another issuer: run canopy login.

Why not docker compose restart <service>

restart keeps the container and its environment, so a service restarted that way keeps the old IDENTITY_ISSUER after a port move, and a partial restart leaves peers on different values: each bespoke restart produces a fresh 401 signature elsewhere in the dependency graph. cargo xtask dev reload recreates every service in the right order in one shot.

What NOT to do

  • Don’t restart canopy-web alone. It sends each worker’s delegation; the receivers judge it.

  • Don’t dismiss the refusals as a flake to retry. Read the rule first: it names the cause.

Edit this page · default