java.lang.Object
io.helidon.webserver.security.SecurityFeature
- All Implemented Interfaces:
io.helidon.builder.api.RuntimeType.Api<SecurityFeatureConfig>,io.helidon.common.config.NamedService,ServerFeature
public class SecurityFeature
extends Object
implements ServerFeature, io.helidon.builder.api.RuntimeType.Api<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).builder()Fluent API builder to set up an instance.static SecurityFeaturecreate(SecurityFeatureConfig config) Create a new instance from its configuration.static SecurityFeaturecreate(Consumer<SecurityFeatureConfig.Builder> builderConsumer) Create a new instance customizing its configuration.static SecurityHandlerenforce()Return a default instance to create a default enforcement point (or modify the result further).name()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) type()
-
Method Details
-
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
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
- Specified by:
prototypein interfaceio.helidon.builder.api.RuntimeType.Api<SecurityFeatureConfig>
-
name
- Specified by:
namein interfaceio.helidon.common.config.NamedService
-
type
- Specified by:
typein interfaceio.helidon.common.config.NamedService
-
setup
- Specified by:
setupin interfaceServerFeature
-