spring-projects / spring-projects/spring-security
Allow configuring a java.time.Clock in OAuth2Authorization.Token
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Expected Behavior
It should be possible to configure a custom java.time.Clock on OAuth2Authorization
(via OAuth2Authorization.Builder), so that Token#isExpired(), #isBeforeUse(), and
#isActive() evaluate against the injected Clock instead of the system clock.
Current Behavior
OAuth2Authorization.Token#isExpired() and #isBeforeUse() compare token timestamps
(expiresAt, nbf claim) directly against Instant.now() / the system clock, with no way
to override this externally.
Context
Writing deterministic tests for token expiry, not-yet-valid (nbf), and revocation/refresh
flows currently requires either Thread.sleep(...), constructing tokens with timestamps
computed relative to Instant.now() at test-build time, or mocking static methods — all of
which are brittle or awkward. Injecting a Clock would make these scenarios reproducible
and independent of wall-clock time.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at OAuth2Authorization.Builder and OAuth2Authorization.Token, then trace how isExpired(), isBeforeUse(), and isActive() currently obtain the system time. Define the configured-clock behavior, including the default when no clock is supplied, and verify expiry, nbf, and revocation or refresh scenarios become deterministic without changing existing behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100