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 |
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 ( |
401 |
Every receiver refuses the tokens it is sent; the log names the rule. |
The receivers' log line (Read the logs first). |
401 |
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 ( |
The token is valid; the route’s admission refused the caller. |
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 issuer identifier moved: canopy-web’s public origin changed (on the devstack, a |
|
A refetch found no such key: it was revoked (canopy-web’s |
|
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 caller sent another service’s token: a defect in the caller. |
|
The compiled call graph has no such edge: a defect in the caller, or services built from different commits. |
keys_unavailable: the key set
-
Is canopy-security up?
cargo xtask dev status, then its/readyz(Deployment Guide › Health). Itsidentity_keycheck reports whether a key can sign and publication is healthy;pendingfor the first minute after boot is the first key’s 60 s publish lead. -
Does its JWKS answer? From inside the network,
GET http://canopy-security:8012/identity/jwkson the devstack (the receivers'IDENTITY_INTERNAL_URLplus/jwks). An emptykeysarray verifies nothing. -
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)
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.
Related
-
Dashboard E2E flake — a different structural flake with overlapping symptoms (an empty dashboard); the disambiguator is whether the refusals are in the logs.
-
IdP Integration › Troubleshooting — sign-in and boot failures.
-
Troubleshooting — general devstack recovery.