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 aExpressionJwtGrantedAuthoritiesConverter
using the providedauthoritiesClaimExpression
. -
Method Summary
Modifier and TypeMethodDescriptionExtractGrantedAuthority
s from the givenJwt
.void
setAuthorityPrefix
(String authorityPrefix) Sets the prefix to use forauthorities
mapped by this converter.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Constructor Details
-
ExpressionJwtGrantedAuthoritiesConverter
public ExpressionJwtGrantedAuthoritiesConverter(org.springframework.expression.Expression authoritiesClaimExpression) Constructs aExpressionJwtGrantedAuthoritiesConverter
using the providedauthoritiesClaimExpression
.- Parameters:
authoritiesClaimExpression
- The token claim SpEL Expression to map authorities from.
-
-
Method Details
-
setAuthorityPrefix
Sets the prefix to use forauthorities
mapped by this converter. Defaults to"SCOPE_"
.- Parameters:
authorityPrefix
- The authority prefix
-
convert
ExtractGrantedAuthority
s from the givenJwt
.- Specified by:
convert
in interfaceorg.springframework.core.convert.converter.Converter<Jwt,
Collection<GrantedAuthority>> - Parameters:
jwt
- TheJwt
token- Returns:
- The
authorities
read from the token scopes
-