Class SpinnakerAuthorities

java.lang.Object
com.netflix.spinnaker.security.SpinnakerAuthorities

public class SpinnakerAuthorities extends Object
Constants and utilities for working with Spring Security GrantedAuthority objects specific to Spinnaker and Fiat. Spinnaker-specific roles are represented here as granted authorities with the SPINNAKER_ prefix.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final org.springframework.security.core.GrantedAuthority
    Granted authority for Spinnaker administrators.
    static final org.springframework.security.core.GrantedAuthority
    Granted authority for anonymous users.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.security.core.GrantedAuthority
    Creates a granted authority corresponding to the provided name of a role.
    static List<String>
    getRoles(org.springframework.security.core.Authentication authentication)
    Gets the list of roles assigned to the given user.
    static boolean
    hasAnyRole(org.springframework.security.core.Authentication authentication, Collection<String> roles)
    Checks if the given user has any of the provided roles.
    static boolean
    hasRole(org.springframework.security.core.Authentication authentication, String role)
    Checks if the given user has the provided role.
    static boolean
    isAdmin(org.springframework.security.core.Authentication authentication)
    Checks if the given user is a Spinnaker admin.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ADMIN

      public static final String ADMIN
      See Also:
    • ADMIN_AUTHORITY

      public static final org.springframework.security.core.GrantedAuthority ADMIN_AUTHORITY
      Granted authority for Spinnaker administrators.
    • ANONYMOUS_AUTHORITY

      public static final org.springframework.security.core.GrantedAuthority ANONYMOUS_AUTHORITY
      Granted authority for anonymous users.
  • Constructor Details

    • SpinnakerAuthorities

      public SpinnakerAuthorities()
  • Method Details

    • forRoleName

      @Nonnull public static org.springframework.security.core.GrantedAuthority forRoleName(@Nonnull String role)
      Creates a granted authority corresponding to the provided name of a role.
    • isAdmin

      public static boolean isAdmin(@Nullable org.springframework.security.core.Authentication authentication)
      Checks if the given user is a Spinnaker admin.
    • hasRole

      public static boolean hasRole(@Nullable org.springframework.security.core.Authentication authentication, @Nonnull String role)
      Checks if the given user has the provided role.
    • hasAnyRole

      public static boolean hasAnyRole(@Nullable org.springframework.security.core.Authentication authentication, @Nonnull Collection<String> roles)
      Checks if the given user has any of the provided roles.
    • getRoles

      @Nonnull public static List<String> getRoles(@Nullable org.springframework.security.core.Authentication authentication)
      Gets the list of roles assigned to the given user.