6 Commits

Author SHA1 Message Date
d83751ad50
test(jwt): document why arrays are invalid for SpaceDelimited scope
Scope is a space-delimited string per RFC 6749 §3.3. A token with
"scope":[] indicates an issuer bug ([]string instead of SpaceDelimited
in the claims struct). Adds array cases to the existing invalid test
and explains the expected root cause.
2026-03-26 18:21:28 -06:00
95cf5941c4
test(jwt): assert scope array is invalid (issuer []string bug trap)
SpaceDelimited must unmarshal from a space-delimited string per RFC 6749
§3.3, not a JSON array. If a token arrives with "scope":[] the issuer
has a bug (e.g. using []string instead of SpaceDelimited in its claims
struct). This test documents that expectation and will catch any attempt
to silently accept the invalid form.
2026-03-26 17:02:21 -06:00
0fc1ae4da8
Revert "fix(jwt): accept JSON array for SpaceDelimited scope claim"
This reverts commit 2a9cec75efa9f36682e65b675cc8826d3460f455.
2026-03-26 17:01:44 -06:00
2a9cec75ef
fix(jwt): accept JSON array for SpaceDelimited scope claim
Some issuers (e.g. PaperOS) emit `scope` as a JSON array (`[]` or
`["openid","profile"]`) instead of the RFC 6749 space-delimited string.
SpaceDelimited.UnmarshalJSON now accepts both forms; a JSON array
is converted to the equivalent slice. Other non-string, non-array
values still return an error.

Adds test cases: array_values and array_empty.
2026-03-26 16:59:11 -06:00
0d99234914
ref!(auth/jwt): variadic requiredScopes in NewAccessTokenValidator
Distinguishes the two validator constructors by signature:
- NewIDTokenValidator(iss, aud, azp []string) — allowlist semantics
- NewAccessTokenValidator(iss, aud []string, requiredScopes ...string) — requirement semantics

Variadic scopes read naturally at the call site:
  NewAccessTokenValidator(issuers, audiences, "openid", "profile")

Three-state semantics preserved:
  no args        → scope not checked
  []string{}...  → scope must be present (any value)
  "openid", ...  → scope must contain all listed values

Also removes the old gracePeriod parameter from both constructors
(was 0 at all call sites; set GracePeriod on the struct directly
if a non-default value is needed).

Adds TestCov_NewAccessTokenValidator_Scopes covering all three cases.
2026-03-17 08:00:45 -06:00
26bdc0a3db
ref!(auth/jwt): full modern rewrite 2026-03-17 07:49:53 -06:00