CallCredentialsHelper or create the CallCredentials and StubTransformers
yourself.@Deprecated
public final class AuthenticatingClientInterceptors
extends java.lang.Object
CallCredentials and the necessary ClientInterceptors.
This class can be used like this:
@Bean
CallCredentials grpcCallCredentials() {
// Note: This method uses experimental grpc-java-API features.
return CallCredentialsHelper.basicAuthCallCredentials("foo", "bar");
// return CallCredentialsHelper.requirePrivacy(...); // Always a good idea
}
@Bean
ClientInterceptor grpcCallCredentialsInterceptor() {
return AuthenticatingClientInterceptors.callCredentialsInterceptor(grpcCallCredentials());
}
Note: You don't need extra call credentials if you authenticate yourself via certificates.
@Bean
public GlobalClientInterceptorConfigurer basicAuthInterceptorConfigurer() {
return registry -> registry.addClientInterceptors(grpcCallCredentialsInterceptor());
}
GrpcClient.interceptorNames() field to add a bean by name.
@GrpcClient(value = "testChannel", interceptorNames = "grpcCallCredentialsInterceptorForTest")
private Channel testChannel;
| Modifier and Type | Method and Description |
|---|---|
static io.grpc.ClientInterceptor |
basicAuthInterceptor(java.lang.String username,
java.lang.String password)
Deprecated.
Use the (potentially) more secure
CallCredentials. |
static io.grpc.ClientInterceptor |
bearerAuth(java.lang.String token)
Deprecated.
Use
StubTransformers to set the credentials directly on AbstractStubs. |
static io.grpc.ClientInterceptor |
callCredentialsInterceptor(io.grpc.CallCredentials callCredentials)
Deprecated.
Use
StubTransformers to set the credentials directly on AbstractStubs. |
@Deprecated
public static io.grpc.ClientInterceptor basicAuthInterceptor(java.lang.String username,
java.lang.String password)
CallCredentials.ClientInterceptor that adds the given username and passwords as basic auth to all requests.
The header will be encoded with UTF_8.username - The username to use.password - The password to use.CallCredentialsHelper.encodeBasicAuth(String, String)@Deprecated public static io.grpc.ClientInterceptor callCredentialsInterceptor(io.grpc.CallCredentials callCredentials)
StubTransformers to set the credentials directly on AbstractStubs.ClientInterceptor that will attach the given call credentials to the given call. This is an
alternative to manually configuring the stubs using AbstractStub.withCallCredentials(CallCredentials).callCredentials - The call credentials to attach.Basic-Auth@Deprecated public static io.grpc.ClientInterceptor bearerAuth(java.lang.String token)
StubTransformers to set the credentials directly on AbstractStubs.ClientInterceptor that adds the given bearer token as Bearer Authentication to all
requests. The header will be encoded with UTF_8.token - the bearer token