Class SecuredAnnotationRule

java.lang.Object
io.micronaut.security.rules.AbstractSecurityRule<io.micronaut.http.HttpRequest<?>>
io.micronaut.security.rules.SecuredAnnotationRule
All Implemented Interfaces:
io.micronaut.core.order.Ordered, SecurityRule<io.micronaut.http.HttpRequest<?>>

@Requires(classes=io.micronaut.http.HttpRequest.class) @Singleton public class SecuredAnnotationRule extends AbstractSecurityRule<io.micronaut.http.HttpRequest<?>>
Security rule implementation for the Secured annotation.
Since:
1.0
Author:
James Kleeh
  • Field Details

    • ORDER

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

    • SecuredAnnotationRule

      public SecuredAnnotationRule(RolesFinder rolesFinder)
      Parameters:
      rolesFinder - Roles Parser
  • Method Details

    • check

      public org.reactivestreams.Publisher<SecurityRuleResult> check(io.micronaut.http.HttpRequest<?> request, @Nullable Authentication authentication)
      Returns SecurityRuleResult.UNKNOWN if the Secured annotation is not found on the method or class, or if the route match is not method based.

      If the Secured value is an expression, the request is allowed only when the expression evaluates to true. An expression that evaluates to null, for example one that navigates the user with user?. for an anonymous request, rejects the request instead of deferring to later rules.

      Parameters:
      request - The current request
      authentication - The authentication, or null if none found
      Returns:
      The result
      See Also:
    • getOrder

      public int getOrder()