Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public AuthenticationProcessInterceptor(AuthenticationManager authenticationMana
public <ReqT, RespT> Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers,
ServerCallHandler<ReqT, RespT> next) {
SecurityContext securityContext = SecurityContextHolder.getContext();
Authentication user = this.extractor.extract(headers, call.getAttributes());
Authentication user = this.extractor.extract(headers, call.getAttributes(), call.getMethodDescriptor());
if (user != null) {
user = this.authenticationManager.authenticate(user);
securityContext.setAuthentication(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import io.grpc.Attributes;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;

/**
* Extracts the HTTP Basic authentication credentials from the gRPC request headers. If
Expand All @@ -36,7 +37,7 @@
public class BearerTokenAuthenticationExtractor implements GrpcAuthenticationExtractor {

@Override
public Authentication extract(Metadata headers, Attributes attributes) {
public Authentication extract(Metadata headers, Attributes attributes, MethodDescriptor<?, ?> method) {
String auth = headers.get(GrpcSecurity.AUTHORIZATION_KEY);
if (auth == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

import io.grpc.Attributes;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;

public interface GrpcAuthenticationExtractor {

Authentication extract(Metadata headers, Attributes attributes);
Authentication extract(Metadata headers, Attributes attributes, MethodDescriptor<?, ?> method);

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import io.grpc.Attributes;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.micrometer.observation.ObservationRegistry;

/**
Expand Down Expand Up @@ -196,9 +197,9 @@ private static class CompositeAuthenticationExtractor implements GrpcAuthenticat
}

@Override
public Authentication extract(Metadata headers, Attributes attributes) {
public Authentication extract(Metadata headers, Attributes attributes, MethodDescriptor<?, ?> method) {
for (GrpcAuthenticationExtractor extractor : this.extractors) {
Authentication authentication = extractor.extract(headers, attributes);
Authentication authentication = extractor.extract(headers, attributes, method);
if (authentication != null) {
return authentication;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import io.grpc.Attributes;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;

/**
* Extracts the HTTP Basic authentication credentials from the gRPC request headers. If
Expand All @@ -37,7 +38,7 @@
public class HttpBasicAuthenticationExtractor implements GrpcAuthenticationExtractor {

@Override
public Authentication extract(Metadata headers, Attributes attributes) {
public Authentication extract(Metadata headers, Attributes attributes, MethodDescriptor<?, ?> method) {
String auth = headers.get(GrpcSecurity.AUTHORIZATION_KEY);
if (auth == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import io.grpc.Attributes;
import io.grpc.Grpc;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;

public class SslContextPreAuthenticationExtractor implements GrpcAuthenticationExtractor {

Expand All @@ -45,7 +46,7 @@ public SslContextPreAuthenticationExtractor(X509PrincipalExtractor principalExtr
}

@Override
public Authentication extract(Metadata headers, Attributes attributes) {
public Authentication extract(Metadata headers, Attributes attributes, MethodDescriptor<?, ?> method) {
SSLSession session = attributes.get(Grpc.TRANSPORT_ATTR_SSL_SESSION);
if (session != null) {
X509Certificate[] certificates = initCertificates(session);
Expand Down