Class ConfigurationInterceptUrlMapRule
- All Implemented Interfaces:
io.micronaut.core.order.Ordered, SecurityRule<io.micronaut.http.HttpRequest<?>>
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.Patterns restricted to the request method take precedence over patterns without a method. A HEAD request matched to the implicit HEAD route the router derives from a
@Getmethod is additionally subject to the patterns restricted to GET, unless a pattern restricted to HEAD matches, because the@Getmethod answers it. Likewise, a request that no route matches is subject to the patterns restricted to GET whatever its method, because static resources are served for any method when no route matches. A HEAD request matched to an explicitly declared@Headmethod is matched like any other request: by the patterns restricted to HEAD, then by the patterns without a method.- 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.