LAB-013: Opaque Token Introspection¶
Status: Verified
Theory: Opaque Token Introspection
Objective¶
Demonstrate a resource server that validates bearer tokens by introspection rather than by decoding a JWT, including active, expired, missing, revoked, and scope-based cases.
Implementation map¶
| Artifact | Purpose |
|---|---|
InMemoryOpaqueTokenRepository | Learning store for opaque reference tokens with expiry and scope |
LocalOpaqueTokenIntrospector | In-process OpaqueTokenIntrospector returning OAuth2AuthenticatedPrincipal |
OpaqueTokenResourceServerConfig | /op/** chain using oauth2ResourceServer().opaqueToken().introspector(...) |
OpaqueTokenController | Lab issue/revoke/introspect endpoints |
OpaqueResourceController | Protected /op/resource and /op/admin/resource |
OpaqueTokenIntrospectionLabTest | Nine positive and negative scenarios |
Exercises¶
- Issue a token with
USERscope and access/op/resource. - Access
/op/admin/resourcewith theUSERtoken and observe 403. - Issue an
ADMINtoken and access the admin resource. - Send a request with no token and observe 401.
- Send an unknown token and observe 401.
- Issue a token, wait / force expiry by backdating, and observe 401.
- Revoke a token and confirm subsequent calls return 401.
- Call
/op/introspectfor an active and an unknown token and compare responses. - Explain why
SCOPE_is the default authority prefix for opaque tokens.
Verification¶
All nine scenarios pass in-process without Docker.
Attack checks¶
- Confirm a well-formed random string that is not in the repository is rejected.
- Confirm a token with the right shape but past expiry is rejected.
- Confirm revocation is immediate, not bound to a TTL.
- Confirm the introspection endpoint does not leak internal attributes for inactive tokens.
Production extension¶
Use NimbusOpaqueTokenIntrospector against a real IdP, authenticate the resource server with client credentials, call over TLS, and implement a bounded cache with eager invalidation on revocation.
Review¶
Complete the token introspection questions in the SSO and Federation Quiz.
Next: LAB-014 Service-to-Service and Client Credentials