public final class JwtAuthenticationProvider
extends java.lang.Object
implements org.springframework.security.authentication.AuthenticationProvider
AuthenticationProvider implementation of the Jwt-encoded
Bearer
Tokens for protecting OAuth 2.0 Resource Servers.
This AuthenticationProvider is responsible for decoding and verifying a
Jwt-encoded access token, returning its claims set as part of the
Authentication statement.
Scopes are translated into GrantedAuthoritys according to the following
algorithm:
1. If there is a "scope" or "scp" attribute, then if a String, then split by
spaces and return, or if a Collection, then simply return 2. Take the resulting
Collection of Strings and prepend the "SCOPE_" keyword, adding as
GrantedAuthoritys.
AuthenticationProvider,
JwtDecoder| Constructor and Description |
|---|
JwtAuthenticationProvider(org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder) |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.security.core.Authentication |
authenticate(org.springframework.security.core.Authentication authentication)
Decode and validate the
Bearer
Token.
|
void |
setJwtAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,? extends org.springframework.security.authentication.AbstractAuthenticationToken> jwtAuthenticationConverter) |
boolean |
supports(java.lang.Class<?> authentication) |
public JwtAuthenticationProvider(org.springframework.security.oauth2.jwt.JwtDecoder jwtDecoder)
public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication authentication)
throws org.springframework.security.core.AuthenticationException
authenticate in interface org.springframework.security.authentication.AuthenticationProviderauthentication - the authentication request object.org.springframework.security.core.AuthenticationException - if authentication failed for some reasonpublic boolean supports(java.lang.Class<?> authentication)
supports in interface org.springframework.security.authentication.AuthenticationProviderpublic void setJwtAuthenticationConverter(org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,? extends org.springframework.security.authentication.AbstractAuthenticationToken> jwtAuthenticationConverter)