Spring / Spring gRPC Interview Questions
How would you restrict which gRPC methods a caller can access, i.e. authorization?
Authorization is typically implemented in a ServerInterceptor that runs after authentication has already populated the caller's identity (whether from a validated JWT or from an mTLS client certificate). The interceptor inspects the method being called (available from the call's descriptor) against the caller's roles or permissions, and rejects the call with Status.PERMISSION_DENIED if the check fails.
Unlike Spring Security's @PreAuthorize for REST controllers, there's no built-in method-level annotation for gRPC in vanilla Spring, so per-method authorization rules are usually expressed as explicit interceptor logic (e.g., a lookup table of service/method name to required role) rather than declarative annotations, unless a project adds its own custom annotation-processing layer for this.
More Related questions...