Class ExpressionJwtGrantedAuthoritiesConverter

java.lang.Object
org.springframework.security.oauth2.server.resource.authentication.ExpressionJwtGrantedAuthoritiesConverter
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>

public final class ExpressionJwtGrantedAuthoritiesConverter extends Object implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>
Uses an expression for extracting the token claim value to use for mapping authorities. Note this can be used in combination with a DelegatingJwtGrantedAuthoritiesConverter.
Since:
6.4
  • Constructor Details

    • ExpressionJwtGrantedAuthoritiesConverter

      public ExpressionJwtGrantedAuthoritiesConverter(org.springframework.expression.Expression authoritiesClaimExpression)
      Constructs a ExpressionJwtGrantedAuthoritiesConverter using the provided authoritiesClaimExpression.
      Parameters:
      authoritiesClaimExpression - The token claim SpEL Expression to map authorities from.
  • Method Details

    • setAuthorityPrefix

      public void setAuthorityPrefix(String authorityPrefix)
      Sets the prefix to use for authorities mapped by this converter. Defaults to "SCOPE_".
      Parameters:
      authorityPrefix - The authority prefix
    • convert

      public Collection<org.springframework.security.core.GrantedAuthority> convert(org.springframework.security.oauth2.jwt.Jwt jwt)
      Extract GrantedAuthoritys from the given Jwt.
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,Collection<org.springframework.security.core.GrantedAuthority>>
      Parameters:
      jwt - The Jwt token
      Returns:
      The authorities read from the token scopes