Class DefaultRolesFinder

java.lang.Object
io.micronaut.security.token.DefaultRolesFinder
All Implemented Interfaces:
RolesFinder

@Singleton public class DefaultRolesFinder extends Object implements RolesFinder
Default implementation of RolesFinder.

The implementation reads roles from the attribute configured by TokenConfiguration.getRolesName(). If the value is a string and TokenConfiguration.getRolesSeparator() is configured, the value is split with that separator. Iterable values are converted to a list of strings.

Since:
1.1.0
Author:
Sergio del Amo
  • Constructor Details

    • DefaultRolesFinder

      public DefaultRolesFinder(TokenConfiguration tokenConfiguration)
      Constructs a default roles finder.
      Parameters:
      tokenConfiguration - General token configuration
  • Method Details

    • resolveRoles

      public @NonNull List<String> resolveRoles(@Nullable Map<String,Object> attributes)
      Description copied from interface: RolesFinder
      Resolves granted roles from the user's authentication attributes.

      Implementations should return an empty list when the attributes are null or no roles can be resolved.

      Specified by:
      resolveRoles in interface RolesFinder
      Parameters:
      attributes - The user's authentication attributes
      Returns:
      The granted roles