Class GrpcSecurityHandler
java.lang.Object
io.helidon.webserver.grpc.security.GrpcSecurityHandler
- All Implemented Interfaces:
io.grpc.ServerInterceptor,RuntimeType.Api<GrpcSecurityHandlerConfig>,GrpcMethodDescriptor.Configurer,GrpcServiceDescriptor.Configurer
public final class GrpcSecurityHandler
extends Object
implements io.grpc.ServerInterceptor, GrpcServiceDescriptor.Configurer, GrpcMethodDescriptor.Configurer, RuntimeType.Api<GrpcSecurityHandlerConfig>
Per-service or per-method security rules for gRPC security.
Register GrpcSecurity on gRPC routing to enforce authentication, authorization, and auditing.
A handler attached directly to a gRPC service or method descriptor only selects the rules used by
GrpcSecurity; by itself it does not enforce security.
-
Method Summary
Modifier and TypeMethodDescriptionaudit()Audit a request.auditEventType(String eventType) Override audit event type.auditMessageFormat(String messageFormat) Override audit message format.Authenticate a request.Allow anonymous access when authentication fails.authenticator(String explicitAuthenticator) Use a named authenticator.Authorize a request.authorizer(String explicitAuthorizer) Use a named authorizer.builder()Create a new fluent API builder for security handler.voidApply extra configuration to aGrpcMethodDescriptor.Rules.voidApply extra configuration to aGrpcServiceDescriptor.Rules.static GrpcSecurityHandlerCreate a handler from configuration.static GrpcSecurityHandlercreate(Config config, GrpcSecurityHandler defaults) Create a handler from configuration and defaults.static GrpcSecurityHandlercreate(Consumer<GrpcSecurityHandlerConfig.Builder> consumer) Create a new handler, customizing its configuration.customObject(Object object) Register a custom object for security request(s).<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT, RespT> next) The prototype as it was received when creating this runtime object instance.rolesAllowed(String... roles) Require at least one of the specified roles.Disable auditing.Skip authentication.Skip authorization.
-
Method Details
-
builder
Create a new fluent API builder for security handler.- Returns:
- a new builder
-
create
Create a new handler, customizing its configuration.- Parameters:
consumer- configuration consumer- Returns:
- configured handler
-
create
Create a handler from configuration and defaults.- Parameters:
config- configurationdefaults- defaults- Returns:
- configured handler
-
create
Create a handler from configuration.- Parameters:
config- configuration- Returns:
- configured handler
-
prototype
Description copied from interface:RuntimeType.ApiThe prototype as it was received when creating this runtime object instance.- Specified by:
prototypein interfaceRuntimeType.Api<GrpcSecurityHandlerConfig>- Returns:
- prototype object used to create this instance
-
configure
Description copied from interface:GrpcServiceDescriptor.ConfigurerApply extra configuration to aGrpcServiceDescriptor.Rules.- Specified by:
configurein interfaceGrpcServiceDescriptor.Configurer- Parameters:
rules- theGrpcServiceDescriptor.Rulesto configure
-
configure
Description copied from interface:GrpcMethodDescriptor.ConfigurerApply extra configuration to aGrpcMethodDescriptor.Rules.- Specified by:
configurein interfaceGrpcMethodDescriptor.Configurer- Parameters:
rules- theGrpcMethodDescriptor.Rulesto configure
-
interceptCall
public <ReqT,RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT, RespT> next) - Specified by:
interceptCallin interfaceio.grpc.ServerInterceptor
-
authenticator
Use a named authenticator.- Parameters:
explicitAuthenticator- authenticator name- Returns:
- new handler
-
authorizer
Use a named authorizer.- Parameters:
explicitAuthorizer- authorizer name- Returns:
- new handler
-
rolesAllowed
Require at least one of the specified roles.- Parameters:
roles- allowed roles- Returns:
- new handler
-
authenticationOptional
Allow anonymous access when authentication fails.- Returns:
- new handler
-
authenticate
Authenticate a request.- Returns:
- new handler
-
skipAuthentication
Skip authentication.- Returns:
- new handler
-
customObject
Register a custom object for security request(s).- Parameters:
object- object expected by a security provider- Returns:
- new handler
-
auditEventType
Override audit event type.- Parameters:
eventType- event type- Returns:
- new handler
-
auditMessageFormat
Override audit message format.- Parameters:
messageFormat- message format- Returns:
- new handler
-
authorize
Authorize a request.- Returns:
- new handler
-
skipAuthorization
Skip authorization.- Returns:
- new handler
-
audit
Audit a request.- Returns:
- new handler
-
skipAudit
Disable auditing.- Returns:
- new handler
-