Package io.micronaut.security.config
Class SecurityConfigurationProperties
java.lang.Object
io.micronaut.security.config.SecurityConfigurationProperties
- All Implemented Interfaces:
io.micronaut.core.util.Toggleable
,AuthenticationModeConfiguration
,SecurityConfiguration
@ConfigurationProperties("micronaut.security")
public class SecurityConfigurationProperties
extends Object
implements SecurityConfiguration
Stores configuration for JWT.
- Since:
- 1.0
- Author:
- Sergio del Amo
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final AuthenticationStrategy
The default enable value.static final boolean
The default enable value.static final boolean
The default value whether intercept url patterns should be prepended with the context path.static final boolean
The default reject-not-found value.static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable AuthenticationMode
boolean
boolean
boolean
For cases where no security rule handles a request and it is determined that the request does not match any routes on the server, whether the response should be to reject the request or allow the not found response to be returned.void
setAuthentication
(@Nullable AuthenticationMode authentication) Defines which authentication to use.void
setAuthenticationProviderStrategy
(AuthenticationStrategy authenticationProviderStrategy) Determines how authentication providers should be processed.void
setEnabled
(boolean enabled) If Security is enabled.void
setInterceptUrlMap
(List<InterceptUrlMapPattern> interceptUrlMap) Map that defines the interception patterns.void
setInterceptUrlMapPrependPatternWithContextPath
(boolean interceptUrlMapPrependPatternWithContextPath) Whether the intercept URL patterns should be prepended with context path if defined.void
setIpPatterns
(List<String> ipPatterns) Allowed IP patterns.void
setRejectNotFound
(boolean rejectNotFound)
-
Field Details
-
PREFIX
- See Also:
-
ANYWHERE
- See Also:
-
DEFAULT_ENABLED
public static final boolean DEFAULT_ENABLEDThe default enable value.- See Also:
-
DEFAULT_INTERCEPT_URL_MAP_PREPEND_PATTERN_WITH_CONTEXT_PATH
public static final boolean DEFAULT_INTERCEPT_URL_MAP_PREPEND_PATTERN_WITH_CONTEXT_PATHThe default value whether intercept url patterns should be prepended with the context path.- See Also:
-
DEFAULT_AUTHENTICATION_STRATEGY
The default enable value. -
DEFAULT_REJECT_NOT_FOUND
public static final boolean DEFAULT_REJECT_NOT_FOUNDThe default reject-not-found value.- See Also:
-
-
Constructor Details
-
SecurityConfigurationProperties
public SecurityConfigurationProperties()
-
-
Method Details
-
getAuthentication
- Specified by:
getAuthentication
in interfaceAuthenticationModeConfiguration
- Returns:
- Authentication Model to use
-
setAuthentication
Defines which authentication to use. Defaults to null. Possible values bearer, session, cookie, idtoken. Should only be supplied if the service handles login and logout requests.- Parameters:
authentication
- Login Handler Mode
-
isEnabled
public boolean isEnabled()- Specified by:
isEnabled
in interfaceio.micronaut.core.util.Toggleable
-
getInterceptUrlMap
- Specified by:
getInterceptUrlMap
in interfaceSecurityConfiguration
- Returns:
- a list of
InterceptUrlMapPattern
-
getIpPatterns
- Specified by:
getIpPatterns
in interfaceSecurityConfiguration
- Returns:
- a list of IP Regex patterns. e.g. [192.168.1.*]
-
setEnabled
public void setEnabled(boolean enabled) If Security is enabled. Default value true- Parameters:
enabled
- True if security is enabled
-
isInterceptUrlMapPrependPatternWithContextPath
public boolean isInterceptUrlMapPrependPatternWithContextPath()- Specified by:
isInterceptUrlMapPrependPatternWithContextPath
in interfaceSecurityConfiguration
- Returns:
- Whether the intercept URL patterns should be prepended with context path if defined.
-
setInterceptUrlMapPrependPatternWithContextPath
public void setInterceptUrlMapPrependPatternWithContextPath(boolean interceptUrlMapPrependPatternWithContextPath) Whether the intercept URL patterns should be prepended with context path if defined. Defaults to true.- Parameters:
interceptUrlMapPrependPatternWithContextPath
- Prepend Intercept URL Map pattern with context path
-
setInterceptUrlMap
Map that defines the interception patterns.- Parameters:
interceptUrlMap
- The intercept urls maps
-
setIpPatterns
Allowed IP patterns. Default value (["0.0.0.0"])- Parameters:
ipPatterns
- The IP patterns
-
getAuthenticationProviderStrategy
- Specified by:
getAuthenticationProviderStrategy
in interfaceSecurityConfiguration
- Returns:
- The authentication strategy
-
setAuthenticationProviderStrategy
public void setAuthenticationProviderStrategy(AuthenticationStrategy authenticationProviderStrategy) Determines how authentication providers should be processed. Default value ANY. Possible values: ANY or ALL.- Parameters:
authenticationProviderStrategy
- authentication strategy.
-
isRejectNotFound
public boolean isRejectNotFound()Description copied from interface:SecurityConfiguration
For cases where no security rule handles a request and it is determined that the request does not match any routes on the server, whether the response should be to reject the request or allow the not found response to be returned.- Specified by:
isRejectNotFound
in interfaceSecurityConfiguration
- Returns:
- True if the response should be rejected.
-
setRejectNotFound
public void setRejectNotFound(boolean rejectNotFound) - Parameters:
rejectNotFound
- Whether the server should respond with 401 for requests that do not match any routes on the server, if you set it to false, it will return 404 for requests that do not match any routes on the server. Default value (true).
-