Class AbstractSecurityRule

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected org.reactivestreams.Publisher<SecurityRuleResult> compareRoles​(java.util.List<java.lang.String> requiredRoles, java.util.Collection<java.lang.String> grantedRoles)
      Compares the given roles to determine if the request is allowed by comparing if any of the granted roles is in the required roles list.
      protected java.util.List<java.lang.String> getRoles​(Authentication authentication)
      Appends SecurityRule.IS_ANONYMOUS if not authenticated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.micronaut.core.order.Ordered

        getOrder
    • Constructor Detail

      • AbstractSecurityRule

        @Inject
        public AbstractSecurityRule​(RolesFinder rolesFinder)
        Parameters:
        rolesFinder - Roles Parser
    • Method Detail

      • getRoles

        protected java.util.List<java.lang.String> getRoles​(Authentication authentication)
        Appends SecurityRule.IS_ANONYMOUS if not authenticated. If the claims contain one or more roles, SecurityRule.IS_AUTHENTICATED is appended to the list.
        Parameters:
        authentication - The authentication, or null if none found
        Returns:
        The granted roles
      • compareRoles

        protected org.reactivestreams.Publisher<SecurityRuleResult> compareRoles​(java.util.List<java.lang.String> requiredRoles,
                                                                                 java.util.Collection<java.lang.String> grantedRoles)
        Compares the given roles to determine if the request is allowed by comparing if any of the granted roles is in the required roles list.
        Parameters:
        requiredRoles - The list of roles required to be authorized
        grantedRoles - The list of roles granted to the user
        Returns:
        SecurityRuleResult.REJECTED if none of the granted roles appears in the required roles list. SecurityRuleResult.ALLOWED otherwise.