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.auditErrorSeverity(AuditEvent.AuditSeverity severity) Override the audit severity used for failed requests.auditEventType(String eventType) Override audit event type.auditMessageFormat(String messageFormat) Override audit message format.auditOkSeverity(AuditEvent.AuditSeverity severity) Override the audit severity used for successful requests.Authenticate a request.Allow anonymous access when authentication fails.authenticationOptional(boolean optional) Configure whether authentication failures may continue as anonymous.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.Clear an authenticator inherited from service defaults.Clear an authorizer inherited from service defaults.Clear roles inherited from service defaults.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.securityLevel(SecurityLevel securityLevel) Add a security level discovered from endpoint annotations.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
-
clearAuthenticator
Clear an authenticator inherited from service defaults.- Returns:
- new handler
-
authorizer
Use a named authorizer.- Parameters:
explicitAuthorizer- authorizer name- Returns:
- new handler
-
clearAuthorizer
Clear an authorizer inherited from service defaults.- Returns:
- new handler
-
rolesAllowed
Require at least one of the specified roles.- Parameters:
roles- allowed roles- Returns:
- new handler
-
clearRolesAllowed
Clear roles inherited from service defaults.- Returns:
- new handler
-
securityLevel
Add a security level discovered from endpoint annotations.- Parameters:
securityLevel- security level- Returns:
- new handler
-
authenticationOptional
Allow anonymous access when authentication fails.- Returns:
- new handler
-
authenticationOptional
Configure whether authentication failures may continue as anonymous.- Parameters:
optional- whether authentication is optional- Returns:
- new handler
-
authenticate
-
skipAuthentication
-
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
-
auditOkSeverity
Override the audit severity used for successful requests.- Parameters:
severity- audit severity- Returns:
- new handler
-
auditErrorSeverity
Override the audit severity used for failed requests.- Parameters:
severity- audit severity- Returns:
- new handler
-
authorize
-
skipAuthorization
-
audit
-
skipAudit
-