i2goSignals

goSignals

49. The verification key set is a family-owned goSet.JWKS over keyfunc v3

Date: 2026-11-19

Status

Accepted (issue #399, release train 0.12.0). Amends ADR 0034 §4 and §5.

Context

The 0.12.0 dependency refresh brings every module to latest stable, majors included (planning ADR 0079). MicahParks/keyfunc moved from v2 to v3, and v3 is a rewrite:

Decision

1. The exported type is family-owned. pkg/goSet exports JWKS, VerificationKey{Key, Alg}, NewJwksFromKeys, NewJwksWithAKP, AKPKeys, FetchJwks with JwksOptions, and ErrKIDNotFound. No keyfunc or jwkset type appears in the exported API, so a later keyfunc major is a change inside pkg/goSet only. Close replaces EndBackground; it is nil-safe, idempotent, and does nothing on a static set.

2. A JWKS has two parts, built together from the same bytes.

A refresh builds both parts from one fetched document and swaps them under one lock, so an AKP key rotates exactly like an RSA key. This replaces ADR 0034 §4’s “given keys merged back in on every refresh”.

3. goSet owns the fetch loop, not jwkset. FetchJwks requires a successful first fetch, then runs a ticker at RefreshInterval (default 1h). It also refreshes when a token names a kid the set does not hold, at most once per RefreshRateLimit (default 5m; authSupport uses 1s for issue #115). The rules:

Owning the loop is what lets decision 2 hold. It also gives the refresher a stable stack frame, goSet.(*jwksRemote).loop, which the GH #290 leak tests count.

4. Alg pinning at the key is kept (ADR 0034 §5).

5. One bad JWK is skipped, not fatal. Each non-AKP key is parsed separately and an unusable one is logged and skipped. jwkset’s whole-set parse would cost a receiver every key because of one bad entry.

6. The not-found error keeps the v2 phrase. ErrKIDNotFound reads “goSet: the given key ID was not found in the JWKS”, and a lookup wraps it with the kid (: "rsa-2"). The text is not byte-identical to v2’s, so match with errors.Is. The classifiers that match the substring “key ID” still work.

Consequences

Positive

Negative