Class GrpcSecurity
java.lang.Object
io.helidon.webserver.grpc.security.GrpcSecurity
- All Implemented Interfaces:
io.grpc.ServerInterceptor,NamedService,NamedService,GrpcServiceDescriptor.Configurer,GrpcServerService
public final class GrpcSecurity
extends Object
implements io.grpc.ServerInterceptor, GrpcServerService, GrpcServiceDescriptor.Configurer
Integration of security into the gRPC server.
The interceptor creates a SecurityContext for each gRPC call. Use
securityDefaults(GrpcSecurityHandler) to set defaults for all calls, and use the handler factory methods on this
class to configure security for services or methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe value used for the key of the security context environment's ABAC request headers attribute.static final StringThe value used for the key of the security context environment's ABAC request method descriptor attribute.static final StringThe value used for the key of the security context environment's ABAC request remote address attribute.static final StringThe value used for the key of the security context environment's ABAC request remote port attribute.Security can accept additional headers to be added to security request.static final io.grpc.Context.Key<GrpcSecurityHandler> The default security handler gRPC context key.static final io.grpc.Context.Key<SecurityContext> The security context gRPC context key. -
Method Summary
Modifier and TypeMethodDescriptionstatic GrpcSecurityHandlerAuthenticate if possible and continue as anonymous on authentication failure.static GrpcSecurityHandleraudit()Audit a request.static GrpcSecurityHandlerAuthenticate a request.static GrpcSecurityHandlerauthenticator(String explicitAuthenticator) Use a named authenticator.static GrpcSecurityHandlerAuthorize a request.static GrpcSecurityHandlerauthorizer(String explicitAuthorizer) Use a named authorizer.voidApply extra configuration to aGrpcServiceDescriptor.Rules.static GrpcSecurityCreate a new gRPC security interceptor from configuration.static GrpcSecurityCreate a new gRPC security interceptor.static GrpcSecurityCreate a new gRPC security interceptor from security and configuration.static GrpcSecurityHandlerenforce()Return a default handler to customize.<ReqT,RespT>
io.grpc.ServerCall.Listener<ReqT> interceptCall(io.grpc.ServerCall<ReqT, RespT> call, io.grpc.Metadata headers, io.grpc.ServerCallHandler<ReqT, RespT> next) WeightedBag<io.grpc.ServerInterceptor> Insert a list of server interceptors for a gRPC call.static GrpcSecurityHandlerrolesAllowed(String... roles) Require at least one of the specified roles.static GrpcSecurityHandlersecure()Secure access using authentication and authorization.securityDefaults(GrpcSecurityHandler defaultHandler) Create a new gRPC security instance using the provided handler as the least-significant default.type()Type of this implementation, to distinguish instances of same type, with differentNamedService.name().Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.webserver.grpc.spi.GrpcServerService
name
-
Field Details
-
CONTEXT_ADD_HEADERS
Security can accept additional headers to be added to security request. -
SECURITY_CONTEXT
The security context gRPC context key. -
GRPC_SECURITY_HANDLER
The default security handler gRPC context key. -
ABAC_ATTRIBUTE_REMOTE_ADDRESS
The value used for the key of the security context environment's ABAC request remote address attribute.- See Also:
-
ABAC_ATTRIBUTE_REMOTE_PORT
The value used for the key of the security context environment's ABAC request remote port attribute.- See Also:
-
ABAC_ATTRIBUTE_HEADERS
The value used for the key of the security context environment's ABAC request headers attribute.- See Also:
-
ABAC_ATTRIBUTE_METHOD
The value used for the key of the security context environment's ABAC request method descriptor attribute.- See Also:
-
-
Method Details
-
create
Create a new gRPC security interceptor.- Parameters:
security- initialized security- Returns:
- gRPC security
-
create
Create a new gRPC security interceptor from configuration.The configuration instance may be the root config or a
grpc-services.securitynode. The security instance is created from the rootsecuritynode.- Parameters:
config- configuration- Returns:
- gRPC security
-
create
Create a new gRPC security interceptor from security and configuration.The configuration instance may be the root config or a
grpc-services.securitynode.- Parameters:
security- initialized securityconfig- configuration- Returns:
- gRPC security
-
secure
Secure access using authentication and authorization.- Returns:
- security handler
-
authenticate
Authenticate a request.- Returns:
- security handler
-
audit
Audit a request.- Returns:
- security handler
-
authenticator
Use a named authenticator.- Parameters:
explicitAuthenticator- authenticator name- Returns:
- security handler
-
authorizer
Use a named authorizer.- Parameters:
explicitAuthorizer- authorizer name- Returns:
- security handler
-
rolesAllowed
Require at least one of the specified roles.- Parameters:
roles- allowed roles- Returns:
- security handler
-
allowAnonymous
Authenticate if possible and continue as anonymous on authentication failure.- Returns:
- security handler
-
authorize
Authorize a request.- Returns:
- security handler
-
enforce
Return a default handler to customize.- Returns:
- security handler
-
securityDefaults
Create a new gRPC security instance using the provided handler as the least-significant default.- Parameters:
defaultHandler- default security handler- Returns:
- gRPC security
-
type
Description copied from interface:NamedServiceType of this implementation, to distinguish instances of same type, with differentNamedService.name(). Use for exampleConfiguredProvider.configKey()to define the type.- Specified by:
typein interfaceGrpcServerService- Specified by:
typein interfaceNamedService- Specified by:
typein interfaceNamedService- Returns:
- type of this service
-
interceptors
Description copied from interface:GrpcServerServiceInsert a list of server interceptors for a gRPC call.- Specified by:
interceptorsin interfaceGrpcServerService- Returns:
- weighted bag of interceptors
-
configure
Description copied from interface:GrpcServiceDescriptor.ConfigurerApply extra configuration to aGrpcServiceDescriptor.Rules.- Specified by:
configurein interfaceGrpcServiceDescriptor.Configurer- Parameters:
rules- theGrpcServiceDescriptor.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
-