java Authentication API custom implementation

26 views
Skip to first unread message

eleano...@gmail.com

unread,
Sep 13, 2018, 5:03:36 PM9/13/18
to grpc.io
Hi 

my current project is using gRPC (java) for service communications. We have our own way of authenticate and authorize the client request. Reading from https://grpch


Q1: is this the interface that I should implement?
public interface CallCredentials {}

Q2: given the code example in this class (see below), it seems it will carry credential information for rpc calls, 
is there a way I can pass the credentials when creating the channel?

FooGrpc.FooStub stub = FooGrpc.newStub(channel);
response = stub.withCallCredentials(creds).bar(request);

Q3: how should I plugin the custom authentication/authorization mechanism on gRPC server side?

Thanks a lot!

Penn (Dapeng) Zhang

unread,
Sep 13, 2018, 5:55:52 PM9/13/18
to grpc.io


On Thursday, September 13, 2018 at 2:03:36 PM UTC-7, eleano...@gmail.com wrote:
Hi 

my current project is using gRPC (java) for service communications. We have our own way of authenticate and authorize the client request. Reading from https://grpch


Q1: is this the interface that I should implement?
public interface CallCredentials {}

That's right if you implement custom authentication. If you are using Google-auth, use io.grpc.auth.MoreCallCredentals.from(googleCreds).
 
Q2: given the code example in this class (see below), it seems it will carry credential information for rpc calls, 
is there a way I can pass the credentials when creating the channel?

FooGrpc.FooStub stub = FooGrpc.newStub(channel);
response = stub.withCallCredentials(creds).bar(request);
To create a channel carrying creds, you might need to use channel = io.grpc.ClientInterceptors.intercept(channel, callOptionsInterceptor), and implement a ClientInterceptor callOptionsInterceptor that injects creds into the callOptions.
 

Q3: how should I plugin the custom authentication/authorization mechanism on gRPC server side?

For server side, the answer can be found here:

Thanks a lot!

eleano...@gmail.com

unread,
Sep 13, 2018, 6:17:52 PM9/13/18
to grpc.io
Hi Penn, 

Thanks a lot! will take a look!
Reply all
Reply to author
Forward
0 new messages