Class ConfigurationInterceptUrlMapRule
java.lang.Object
io.micronaut.security.rules.AbstractSecurityRule<io.micronaut.http.HttpRequest<?>>
io.micronaut.security.rules.ConfigurationInterceptUrlMapRule
- All Implemented Interfaces:
io.micronaut.core.order.Ordered, SecurityRule<io.micronaut.http.HttpRequest<?>>
@Requires(classes=io.micronaut.http.HttpRequest.class) @Requires(beans={RolesFinder.class,SecurityConfiguration.class,InterceptUrlPatternModifier.class})
@Singleton
public class ConfigurationInterceptUrlMapRule
extends AbstractSecurityRule<io.micronaut.http.HttpRequest<?>>
A security rule implementation backed by the
SecurityConfiguration.getInterceptUrlMap().- Since:
- 1.0
- Author:
- Sergio del Amo
-
Field Summary
FieldsFields inherited from interface io.micronaut.core.order.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCEFields inherited from interface SecurityRule
DENY_ALL, IS_ANONYMOUS, IS_AUTHENTICATED -
Constructor Summary
ConstructorsConstructorDescriptionConfigurationInterceptUrlMapRule(RolesFinder rolesFinder, SecurityConfiguration securityConfiguration, InterceptUrlPatternModifier interceptUrlPatternModifier) Deprecated, for removal: This API element is subject to removal in a future version.ConfigurationInterceptUrlMapRule(RolesFinder rolesFinder, SecurityConfiguration securityConfiguration, InterceptUrlPatternModifier interceptUrlPatternModifier, @Nullable io.micronaut.http.context.ServerContextPathProvider serverContextPathProvider) -
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<SecurityRuleResult> check(io.micronaut.http.HttpRequest<?> request, @Nullable Authentication authentication) If no configured pattern matches the request, returnSecurityRuleResult.UNKNOWN.protected Optional<InterceptUrlMapPattern> findPattern(io.micronaut.http.HttpRequest<?> request) Finds the first configured pattern that applies to the request, using the same method-specific precedence asSecurityRule.check(HttpRequest, Authentication).intgetOrder()protected List<InterceptUrlMapPattern> Provides a list ofInterceptUrlMapPatternwhich will be used to provideSecurityRule.booleanisAnonymous(io.micronaut.http.HttpRequest<?> request) Whether the first configured pattern that applies to the request allows anonymous access.protected booleanmatchesPath(@NonNull String pattern, @NonNull String path) Whether a configured pattern matches a request path.Methods inherited from class AbstractSecurityRule
compareRoles, getRoles
-
Field Details
-
ORDER
The order of the rule.
-
-
Constructor Details
-
ConfigurationInterceptUrlMapRule
@Deprecated(forRemoval=true, since="5.5.2") public ConfigurationInterceptUrlMapRule(RolesFinder rolesFinder, SecurityConfiguration securityConfiguration, InterceptUrlPatternModifier interceptUrlPatternModifier) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
rolesFinder- Roles ParsersecurityConfiguration- The Security ConfigurationinterceptUrlPatternModifier- InterceptURLMap modifier
-
ConfigurationInterceptUrlMapRule
@Inject public ConfigurationInterceptUrlMapRule(RolesFinder rolesFinder, SecurityConfiguration securityConfiguration, InterceptUrlPatternModifier interceptUrlPatternModifier, @Nullable io.micronaut.http.context.ServerContextPathProvider serverContextPathProvider) - Parameters:
rolesFinder- Roles ParsersecurityConfiguration- The Security ConfigurationinterceptUrlPatternModifier- InterceptURLMap modifierserverContextPathProvider- Server context path provider- Since:
- 5.5.2
-
-
Method Details
-
getPatternList
Provides a list ofInterceptUrlMapPatternwhich will be used to provideSecurityRule.- Returns:
- List of
InterceptUrlMapPattern
-
getOrder
public int getOrder() -
matchesPath
Whether a configured pattern matches a request path.The request path is compared with its trailing slash trimmed (except for the root), so a trailing slash in the pattern is trimmed the same way. Otherwise, a pattern such as
/context/, which is what the root pattern/becomes once the server context path is prepended, would never match any request.Requests for the context root (
/contextor/context/) are the application's root route. They are matched as the root path/is matched when no context path is set, so that patterns such as/context/*apply to them.- Parameters:
pattern- The configured Ant-style patternpath- The request path with any trailing slash trimmed, except for the root path- Returns:
- Whether the pattern matches the path
-
isAnonymous
@Internal public boolean isAnonymous(io.micronaut.http.HttpRequest<?> request) Whether the first configured pattern that applies to the request allows anonymous access.- Parameters:
request- The current request- Returns:
- Whether authentication resolution can be skipped for the request
- Since:
- 5.4.0
-
check
public org.reactivestreams.Publisher<SecurityRuleResult> check(io.micronaut.http.HttpRequest<?> request, @Nullable Authentication authentication) If no configured pattern matches the request, returnSecurityRuleResult.UNKNOWN. Reads the rules in order. The first matched rule will be used for determining authorization.- Parameters:
request- The current requestauthentication- The user authentication. Null if not authenticated- Returns:
- The result
- See Also:
-
findPattern
Finds the first configured pattern that applies to the request, using the same method-specific precedence asSecurityRule.check(HttpRequest, Authentication).- Parameters:
request- The current request- Returns:
- The matching pattern, if any
-
ConfigurationInterceptUrlMapRule(RolesFinder, SecurityConfiguration, InterceptUrlPatternModifier, ServerContextPathProvider)instead.