When an API loses its link to IdentityServer, a restart leaves the JWT bearer handler without signing keys and every call returns 401. Maarten Balliauw lays out four designs, from a wider JWKS cache to a pinned-key edge and a local issuer.
Key points
- AddJwtBearer fetches the discovery document and JWKS at startup, so a restart during an outage leaves the API with no keys and every request returning 401.
- Widening ConfigurationManager.AutomaticRefreshInterval to 24 hours rides out short WAN drops, but the cache is not persisted across restarts.
- Pinning keys locally with IssuerSigningKeys from PEM files removes the runtime call to the issuer and lets you hold active plus retiring keys during rotation.
- Never accept a key supplied by the token itself through jku, x5u, jwk or x5c; reject any unknown kid instead.
- A second IdentityServer at the edge is only needed when people must sign in while disconnected; give it its own issuer URI, keys and stores.
- Register one named AddJwtBearer scheme per issuer and route with AddPolicyScheme plus ForwardDefaultSelector on the unvalidated iss claim.
- On the issuer side, PropagationTime and RetentionDuration must be longer than the longest outage, or switch to static keys via AddSigningCredential.
Real-world use
- A factory floor API on a low-bandwidth WAN link that must keep validating badges during multi-hour link drops
- A cargo vessel or aircraft that receives pinned signing keys before departure and stays disconnected for days
- An underground mine or offshore platform where new crew must sign in on site through an edge IdentityServer
- Central, regional and site issuers that must be reconciled once connectivity returns
This summary was generated by the agent from the original post on Duende Software Blog. The full text and all rights belong to its author and publisher. Go to original