java.lang.Object
io.helidon.webserver.security.SecurityFeature
- All Implemented Interfaces:
 RuntimeType.Api<io.helidon.webserver.security.SecurityFeatureConfig>,NamedService,ServerFeature
public class SecurityFeature
extends Object
implements ServerFeature, RuntimeType.Api<io.helidon.webserver.security.SecurityFeatureConfig>
Server feature for security, to be registered with
 
WebServerConfig.BuilderBase.addFeature(io.helidon.webserver.spi.ServerFeature).
 
 This feature adds a filter to register SecurityContext
 in request Context,
 and registers HttpRouting.Builder.security(io.helidon.webserver.http.HttpSecurity).
 If configured, it also adds protection points to endpoints.
- 
Nested Class Summary
Nested classes/interfaces inherited from interface io.helidon.webserver.spi.ServerFeature
ServerFeature.RoutingBuilders, ServerFeature.ServerFeatureContext, ServerFeature.SocketBuilders - 
Method Summary
Modifier and TypeMethodDescriptionstatic SecurityHandlerIf called, authentication failure will not abort request and will continue as anonymous (defaults to false).static SecurityHandleraudit()Whether to audit this request - defaults to false for GET and HEAD methods, true otherwise.static SecurityHandlerIf called, request will go through authentication process - defaults to false (even if authorize is true).static SecurityHandlerauthenticator(String explicitAuthenticator) Use a named authenticator (as supported by security - if not defined, default authenticator is used).static SecurityHandlerEnable authorization for this route.static SecurityHandlerauthorizer(String explicitAuthorizer) Use a named authorizer (as supported by security - if not defined, default authorizer is used, if none defined, all is permitted).static io.helidon.webserver.security.SecurityFeatureConfig.Builderbuilder()Fluent API builder to set up an instance.static SecurityFeaturecreate(io.helidon.webserver.security.SecurityFeatureConfig config) Create a new instance from its configuration.static SecurityFeatureCreate a new instance customizing its configuration.static SecurityHandlerenforce()Return a default instance to create a default enforcement point (or modify the result further).name()Name of this implementation, as provided inConfiguredProvider.create(Config, String).io.helidon.webserver.security.SecurityFeatureConfigThe prototype as it was received when creating this runtime object instance.static SecurityHandlerrolesAllowed(String... roles) An array of allowed roles for this path - must have a security provider supporting roles.static SecurityHandlersecure()Secure access using authentication and authorization.voidsetup(ServerFeature.ServerFeatureContext featureContext) Set up a server feature.type()Type of this implementation, to distinguish instances of same type, with differentNamedService.name(). 
- 
Method Details
- 
builder
public static io.helidon.webserver.security.SecurityFeatureConfig.Builder builder()Fluent API builder to set up an instance.- Returns:
 - a new builder
 
 - 
create
Create a new instance from its configuration.- Parameters:
 config- configuration- Returns:
 - a new feature
 
 - 
create
public static SecurityFeature create(Consumer<io.helidon.webserver.security.SecurityFeatureConfig.Builder> builderConsumer) Create a new instance customizing its configuration.- Parameters:
 builderConsumer- consumer of configuration- Returns:
 - a new feature
 
 - 
secure
Secure access using authentication and authorization. Auditing is enabled by default for methods modifying content. When using RBAC (role based access control), just userolesAllowed(String...). If you use a security provider, that requires additional data, useSecurityHandler.customObject(Object).Behavior:
- Authentication: enabled and required
 - Authorization: enabled if provider configured
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Returns:
 SecurityHandlerinstance configured with authentication and authorization
 - 
authenticate
If called, request will go through authentication process - defaults to false (even if authorize is true).Behavior:
- Authentication: enabled and required
 - Authorization: not modified (default: disabled)
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Returns:
 SecurityHandlerinstance
 - 
audit
Whether to audit this request - defaults to false for GET and HEAD methods, true otherwise. Request is audited with event type "request".Behavior:
- Authentication: not modified (default: disabled)
 - Authorization: not modified (default: disabled)
 - Audit: enabled for any method this gate is registered on
 
- Returns:
 SecurityHandlerinstance
 - 
authenticator
Use a named authenticator (as supported by security - if not defined, default authenticator is used).Behavior:
- Authentication: enabled and required
 - Authorization: not modified (default: disabled)
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
SecurityHttpFeature(intentionally has the same class name, so the use cases are re-visited).This type is discovered automatically by
WebServer. To configure it, use theserver.features.securityconfiguration node (for mapping of protected paths). Configuration of security itself is still under root nodesecurity.- Parameters:
 explicitAuthenticator- name of authenticator as configured inSecurity- Returns:
 SecurityHandlerinstance- See Also:
 
 - 
authorizer
Use a named authorizer (as supported by security - if not defined, default authorizer is used, if none defined, all is permitted).Behavior:
- Authentication: enabled and required
 - Authorization: enabled with explicit provider
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Parameters:
 explicitAuthorizer- name of authorizer as configured inSecurity- Returns:
 SecurityHandlerinstance
 - 
rolesAllowed
An array of allowed roles for this path - must have a security provider supporting roles.Behavior:
- Authentication: enabled and required
 - Authorization: enabled
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Parameters:
 roles- if subject is any of these roles, allow access- Returns:
 SecurityHandlerinstance
 - 
allowAnonymous
If called, authentication failure will not abort request and will continue as anonymous (defaults to false).Behavior:
- Authentication: enabled and optional
 - Authorization: not modified (default: disabled)
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Returns:
 SecurityHandlerinstance
 - 
authorize
Enable authorization for this route.Behavior:
- Authentication: enabled and required
 - Authorization: enabled if provider is present
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Returns:
 SecurityHandlerinstance
 - 
enforce
Return a default instance to create a default enforcement point (or modify the result further).Behavior:
- Authentication: not modified (default: disabled)
 - Authorization: not modified (default: disabled)
 - Audit: not modified (default: enabled except for GET and HEAD methods)
 
- Returns:
 SecurityHandlerinstance
 - 
prototype
public io.helidon.webserver.security.SecurityFeatureConfig prototype()Description copied from interface:RuntimeType.ApiThe prototype as it was received when creating this runtime object instance.- Specified by:
 prototypein interfaceRuntimeType.Api<io.helidon.webserver.security.SecurityFeatureConfig>- Returns:
 - prototype object used to create this instance
 
 - 
name
Description copied from interface:NamedServiceName of this implementation, as provided inConfiguredProvider.create(Config, String).- Specified by:
 namein interfaceNamedService- Returns:
 - name of this service
 
 - 
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 interfaceNamedService- Returns:
 - type of this service
 
 - 
setup
Description copied from interface:ServerFeatureSet up a server feature. Server features can modify server configuration, right before the server is created. To access listener configuration, or routing, a list of all listeners is provided.- Specified by:
 setupin interfaceServerFeature- Parameters:
 featureContext- to access builders of webserver, listeners, and routing
 
 -