Skip to content

Document and test OAuth2 opaque token support - #416

Closed
Adrastopoulos wants to merge 1 commit into
spring-projects:mainfrom
Adrastopoulos:gabriel/opaque-token-docs-tests
Closed

Document and test OAuth2 opaque token support#416
Adrastopoulos wants to merge 1 commit into
spring-projects:mainfrom
Adrastopoulos:gabriel/opaque-token-docs-tests

Conversation

@Adrastopoulos

@Adrastopoulos Adrastopoulos commented Jul 29, 2026

Copy link
Copy Markdown

GrpcSecurity's OAuth2 resource server configurer has supported opaque tokens since it was introduced in "Add some oauth2 configuration and sample code", but that path is effectively invisible and unverified:

  • The reference docs mention the OAuth2 resource server in a single sentence and never mention opaqueToken().
  • The grpc-oauth2 sample only demonstrates jwt(withDefaults()).
  • spring-grpc-core had no tests in the security package at all, so the extractors and the jwt()-over-opaqueToken() precedence in getAuthenticationProvider() were uncovered.

This adds:

  • BearerTokenAuthenticationExtractorTests and HttpBasicAuthenticationExtractorTests covering scheme matching (including case-insensitivity), missing headers and malformed credentials.
  • OAuth2ResourceServerConfigurerTests covering both configurers, introspector resolution from the application context, and the precedence rule.
  • OpaqueTokenServerApplicationTests in the grpc-oauth2 sample, which authenticates a real opaque token against a Spring Authorization Server over introspectionUri — mirroring the existing JWT test.
  • Reference docs for the OAuth2 resource server, with worked jwt() and opaqueToken() examples plus notes on introspector()/authenticationConverter() and the precedence rule.

The GrpcSecurity OAuth2 resource server configurer has supported opaque
tokens since it was introduced, but the reference docs only mentioned
OAuth2 in passing and neither token format had test coverage. The
security package had no tests at all, so the extractors and the
jwt()-over-opaqueToken() precedence rule were unverified.

Add unit tests for the bearer and basic extractors and for the resource
server configurer, an end-to-end sample test that authenticates an
opaque token against a real authorization server by introspection, and
expand the server docs with worked jwt() and opaqueToken() examples.

Signed-off-by: Gabriel Hall <gabriel.hall@cox.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant