go-sdk/auth
Repository files (latest commit first)
Filename Latest commit message Latest commit date
BorisTyshkevich 5045d86fb4
auth: add ClockSkew option to RequireBearerTokenOptions (#969)
## Summary

- Add a \`ClockSkew time.Duration\` field to
\`RequireBearerTokenOptions\` that bounds the tolerance applied to a
token's \`Expiration\` when checking elapsed validity.
- Default zero preserves the existing strict comparison; positive values
let resource servers tolerate the drift typical of distributed
deployments and cloud-managed IdPs.

## Motivation

Real-world resource servers running behind a CDN, in distributed
deployments, or talking to an authorization server whose clock drifts a
few seconds (common with cloud-managed IdPs) need a small positive
tolerance when checking token expiration. Strict-equality comparison
rejects tokens that are valid by the issuer's clock but momentarily
appear expired by the verifier's. The reverse case — an issuer's clock
running slightly fast at /token issuance — also reaches the verifier as
a token whose \`exp\` lies microseconds in the past.

## Test plan

- [x] \`go test ./auth/...\` passes.
- [x] New \`TestRequireBearerToken_ClockSkew\` exercises four cases:
fresh accept, strict-expired reject, within-skew accept, beyond-skew
reject.
- [x] Existing \`TestRequireBearerToken\` continues to pass with
\`ClockSkew\` defaulting to zero.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Guglielmo Colombo <guglielmoc@google.com>
2026-06-05 12:16:43 +02:00
..
extauth mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
auth.go auth: add ClockSkew option to RequireBearerTokenOptions (#969) 2026-06-05 12:16:43 +02:00
auth_test.go auth: add ClockSkew option to RequireBearerTokenOptions (#969) 2026-06-05 12:16:43 +02:00
authorization_code.go mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
authorization_code_test.go mcp: add optional issuer validator for pre-registered client validation (SEP-2352) (#946) 2026-05-29 12:46:34 +00:00
client.go Enterprise managed authorization (#770) 2026-03-30 16:29:30 +02:00
shared.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00
shared_test.go all: stabilize client OAuth support (#861) 2026-03-31 12:36:31 +02:00