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 Details

    • ORDER

      public static final Integer ORDER
      The order of the rule.
  • Constructor Details

  • Method Details

    • getPatternList

      protected List<InterceptUrlMapPattern> getPatternList()
      Provides a list of InterceptUrlMapPattern which will be used to provide SecurityRule.
      Returns:
      List of InterceptUrlMapPattern
    • getOrder

      public int getOrder()
    • matchesPath

      protected boolean matchesPath(@NonNull String pattern, @NonNull String path)
      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 (/context or /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 pattern
      path - 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, return SecurityRuleResult.UNKNOWN. Reads the rules in order. The first matched rule will be used for determining authorization.
      Parameters:
      request - The current request
      authentication - The user authentication. Null if not authenticated
      Returns:
      The result
      See Also:
    • findPattern

      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 as SecurityRule.check(HttpRequest, Authentication).
      Parameters:
      request - The current request
      Returns:
      The matching pattern, if any