You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have written the sample code for authorisation using gRPC service. I was unable to find an easy way to implement the service.
import io.grpc.Server;
import io.grpc.ServerBuilder;
public class AuthServer {
public static void main(String[] args) throws Exception {
// Create a new server to listen on port 8081
Server server = ServerBuilder.forPort(5051)
.addService(new ExtAuthService())
.build();
// Start the server
server.start();
// Server threads are running in the background.
System.out
.println("+++++++++++++++++++++++ gRPC server started ++++++++++++++++++++++++++++");
// Don't exit the main thread. Wait until server is terminated.
server.awaitTermination();
}
}
The external authorisation service is follows.
import com.google.rpc.Status;
import io.envoyproxy.envoy.service.auth.v3.AuthorizationGrpc;
import io.envoyproxy.envoy.service.auth.v3.CheckRequest;
import io.envoyproxy.envoy.service.auth.v3.CheckResponse;
import io.envoyproxy.envoy.service.auth.v3.OkHttpResponse;
import io.grpc.stub.StreamObserver;
public class ExtAuthService extends AuthorizationGrpc.AuthorizationImplBase {
@Override
public void check (CheckRequest request, StreamObserver<CheckResponse> responseObserver) {
System.out.println("++++++++++hit+++++++++++++++");
System.out.println(request);
CheckResponse response = CheckResponse.newBuilder()
.setStatus(Status.newBuilder().build())
.setOkResponse(OkHttpResponse.newBuilder().build())
.build();
// Use responseObserver to send a single response back
responseObserver.onNext(response);
// When you are done, you must call onCompleted.
responseObserver.onCompleted();
}
}
I have written the sample code for authorisation using gRPC service. I was unable to find an easy way to implement the service.
The external authorisation service is follows.
Request:
Response:
What am I missing?
The text was updated successfully, but these errors were encountered: