Class ExpressionJwtGrantedAuthoritiesConverter
java.lang.Object
org.springframework.security.oauth2.server.resource.authentication.ExpressionJwtGrantedAuthoritiesConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>>
public final class ExpressionJwtGrantedAuthoritiesConverter
extends Object
implements org.springframework.core.convert.converter.Converter<Jwt,Collection<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 Summary
ConstructorsConstructorDescriptionExpressionJwtGrantedAuthoritiesConverter(org.springframework.expression.Expression authoritiesClaimExpression) Constructs aExpressionJwtGrantedAuthoritiesConverterusing the providedauthoritiesClaimExpression. -
Method Summary
Modifier and TypeMethodDescriptionExtractGrantedAuthoritys from the givenJwt.voidsetAuthorityPrefix(String authorityPrefix) Sets the prefix to use forauthoritiesmapped by this converter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Constructor Details
-
ExpressionJwtGrantedAuthoritiesConverter
public ExpressionJwtGrantedAuthoritiesConverter(org.springframework.expression.Expression authoritiesClaimExpression) Constructs aExpressionJwtGrantedAuthoritiesConverterusing the providedauthoritiesClaimExpression.- Parameters:
authoritiesClaimExpression- The token claim SpEL Expression to map authorities from.
-
-
Method Details
-
setAuthorityPrefix
Sets the prefix to use forauthoritiesmapped by this converter. Defaults to"SCOPE_".- Parameters:
authorityPrefix- The authority prefix
-
convert
ExtractGrantedAuthoritys from the givenJwt.- Specified by:
convertin interfaceorg.springframework.core.convert.converter.Converter<Jwt,Collection<GrantedAuthority>> - Parameters:
jwt- TheJwttoken- Returns:
- The
authoritiesread from the token scopes
-