Skip to content

Document extracting authentication from custom metadata - #417

Closed
Adrastopoulos wants to merge 1 commit into
spring-projects:mainfrom
Adrastopoulos:gabriel/custom-credentials-docs
Closed

Document extracting authentication from custom metadata#417
Adrastopoulos wants to merge 1 commit into
spring-projects:mainfrom
Adrastopoulos:gabriel/custom-credentials-docs

Conversation

@Adrastopoulos

@Adrastopoulos Adrastopoulos commented Jul 29, 2026

Copy link
Copy Markdown

GrpcSecurity.authenticationExtractor(...) is public and accepts any GrpcAuthenticationExtractor, but the reference docs only cover the built-in mechanisms, all of which read the Authorization metadata entry. Credentials that arrive in another metadata key (a session token, an API key header, a gateway-issued principal) have no documented path, even though the extension point already supports them.

Two behaviours of that extension point were also untested:

  • Registered extractors are sorted with AnnotationAwareOrderComparator, so @Order controls precedence.
  • CompositeAuthenticationExtractor returns the first non-null Authentication, so a custom extractor composes with the built-in ones rather than replacing them.

This documents authenticationExtractor() with a worked example and adds GrpcSecurityAuthenticationExtractorTests, which drives calls through the interceptor built by GrpcSecurity and asserts both behaviours.

No main source changes.

Verified with ./mvnw clean install on JDK 25 (144 tests, 0 failures). Code formatted with spring-javaformat:apply per CONTRIBUTING.

GrpcSecurity accepts arbitrary GrpcAuthenticationExtractor instances,
but the reference docs only covered the built-in Authorization header
mechanisms, so credentials carried in other metadata entries had no
documented path. The composition rules were also untested: extractors
are sorted by @order and the first non-null Authentication wins.

Document authenticationExtractor() with a worked example and add tests
covering extractor ordering and first-non-null resolution.

Signed-off-by: Gabriel Hall <gabriel.hall@cox.net>
@Adrastopoulos
Adrastopoulos force-pushed the gabriel/custom-credentials-docs branch from 922bbb2 to bbbeaf2 Compare July 29, 2026 08:10
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