Class BaseAuthenticatingServerInterceptor

java.lang.Object
ir.msob.jima.security.api.grpc.oauth2.BaseAuthenticatingServerInterceptor
All Implemented Interfaces:
io.grpc.ServerInterceptor, net.devh.boot.grpc.server.security.interceptors.AuthenticatingServerInterceptor

@GrpcGlobalServerInterceptor @Order(5100) public class BaseAuthenticatingServerInterceptor extends Object implements net.devh.boot.grpc.server.security.interceptors.AuthenticatingServerInterceptor
BaseAuthenticatingServerInterceptor is a gRPC server interceptor that handles authentication based on JWT tokens. It implements the AuthenticatingServerInterceptor interface and is marked as a global server interceptor. This interceptor extracts the JWT token from the authorization header in the metadata, validates it using the provided GrpcAuthenticationReader, and sets the authenticated user in the security context.
Author:
Yaqub Abdi
  • Field Summary

    Fields inherited from interface net.devh.boot.grpc.server.security.interceptors.AuthenticatingServerInterceptor

    AUTHENTICATION_CONTEXT_KEY, SECURITY_CONTEXT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <ReqT, RespT>
    io.grpc.ServerCall.Listener<ReqT>
    interceptCall(io.grpc.ServerCall<ReqT,RespT> serverCall, io.grpc.Metadata metadata, io.grpc.ServerCallHandler<ReqT,RespT> serverCallHandler)
    Intercepts the gRPC server call, extracts the JWT token from the authorization header, validates it, and sets the authenticated user in the security context.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BaseAuthenticatingServerInterceptor

      public BaseAuthenticatingServerInterceptor()
  • Method Details

    • interceptCall

      public <ReqT, RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT,RespT> serverCall, io.grpc.Metadata metadata, io.grpc.ServerCallHandler<ReqT,RespT> serverCallHandler)
      Intercepts the gRPC server call, extracts the JWT token from the authorization header, validates it, and sets the authenticated user in the security context.
      Specified by:
      interceptCall in interface io.grpc.ServerInterceptor
      Type Parameters:
      ReqT - The type of the request.
      RespT - The type of the response.
      Parameters:
      serverCall - The gRPC server call being intercepted.
      metadata - Metadata associated with the call.
      serverCallHandler - The server call handler.
      Returns:
      A ServerCall.Listener for processing the server call.
      Throws:
      io.grpc.StatusRuntimeException - If authentication fails or an error occurs during the process.