From a05110df60e044b8852ce0eea7ec15b7b9071589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 28 Oct 2026 15:45:17 +0300 Subject: [PATCH] =?UTF-8?q?=E2=8F=B1=EF=B8=8F=20oidc:=20cache=20im's=20key?= =?UTF-8?q?s=20for=20ten=20minutes,=20so=20a=20withdrawn=20key=20stops=20v?= =?UTF-8?q?erifying=20sooner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/in-web/src/oidc.rs | 4 ++-- docs/contracts.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/in-web/src/oidc.rs b/crates/in-web/src/oidc.rs index b6c7c1d..9c15e40 100644 --- a/crates/in-web/src/oidc.rs +++ b/crates/in-web/src/oidc.rs @@ -1,7 +1,7 @@ //! The OpenID Connect client of `in`, a relying party of `im` (docs/contracts.md section 2). //! //! It does four things and nothing more. It finds `im`'s endpoints (discovery, cached, with the -//! standard paths as a fallback). It keeps `im`'s signing keys (JWKS, cached for an hour, refetched at +//! standard paths as a fallback). It keeps `im`'s signing keys (JWKS, cached for ten minutes, refetched at //! most once a minute when a token names an unknown key). It verifies the three kinds of token `in` //! receives: ID tokens, logout tokens and access tokens. And it makes the calls `in` sends to `im`: the //! code exchange and the client-credentials token that the directory and the photos need. @@ -31,7 +31,7 @@ pub const CLOCK_LEEWAY_SECS: i64 = 60; pub const MAX_FUTURE_IAT_SECS: i64 = 300; /// How long a fetched key set is used before it is fetched again (contracts section 2.2). -pub const JWKS_MAX_AGE: Duration = Duration::from_secs(60 * 60); +pub const JWKS_MAX_AGE: Duration = Duration::from_secs(10 * 60); /// The shortest gap between two key fetches. A fetch for an unknown `kid`, and a retry after a failed /// fetch, both wait this long. It is the one-minute refetch limit of contracts section 2.2, and it diff --git a/docs/contracts.md b/docs/contracts.md index f08fbad..1878e49 100644 --- a/docs/contracts.md +++ b/docs/contracts.md @@ -60,7 +60,7 @@ Clients fetch discovery once at boot and cache it. They may hard-code the paths the last 7 days, as `{"kty":"OKP","crv":"Ed25519","x":...,"kid":...,"use":"sig","alg":"EdDSA"}`. - `im` rotates the signing key every 90 days and on admin demand. A new key is published 24 hours before it signs anything. -- Clients cache the JWKS for 1 hour, and refetch at most once a minute when a token names an unknown `kid`. +- Clients cache the JWKS for 10 minutes, and refetch at most once a minute when a token names an unknown `kid`. ### 2.3 Sign-in (authorization code + PKCE)