Skip to content

Commit 72c249f

Browse files
committed
Deprecate AUTHENTICATION_CONTEXT_KEY in favor of SECURITY_CONTEXT_KEY
1 parent 18ab8cb commit 72c249f

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/interceptors/AuthenticatingServerInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ public interface AuthenticatingServerInterceptor extends ServerInterceptor {
5151

5252
/**
5353
* The context key that can be used to retrieve the originally associated {@link Authentication}.
54+
*
55+
* @deprecated Use {@link #SECURITY_CONTEXT_KEY} instead.
5456
*/
57+
@Deprecated
5558
Context.Key<Authentication> AUTHENTICATION_CONTEXT_KEY = Context.key("authentication");
5659

5760
}

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/security/interceptors/DefaultAuthenticatingServerInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(final ServerCall<Re
115115
final SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
116116
securityContext.setAuthentication(authentication);
117117
SecurityContextHolder.setContext(securityContext);
118+
@SuppressWarnings("deprecation")
118119
final Context grpcContext = Context.current().withValues(
119120
SECURITY_CONTEXT_KEY, securityContext,
120121
AUTHENTICATION_CONTEXT_KEY, authentication);

tests/src/test/java/net/devh/boot/grpc/test/server/TestServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ protected void assertSameAuthenticatedGrcContextCancellation(final String method
184184
protected Authentication assertSameAuthenticatedGrcContextOnly(final String method, final Authentication expected,
185185
final Context context) {
186186
return assertSameAuthenticated(method, expected,
187-
AuthenticatingServerInterceptor.AUTHENTICATION_CONTEXT_KEY.get(context));
187+
AuthenticatingServerInterceptor.SECURITY_CONTEXT_KEY.get(context).getAuthentication());
188188
}
189189

190190
protected Authentication assertSameAuthenticated(final String method, final Authentication expected) {

0 commit comments

Comments
 (0)