-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Currently, JwtAuthenticationToken
always pass one Jwt
instance to super constructor (AbstractOAuth2TokenAuthenticationToken
) as token
, principal
and credentials
. So, that implies that all three values must always be a jwt token itself.
I don't see any reason why principal
in JWT token must always be the token itself. It already represents both token
and credentials
. But for principal
I want more flexibility: an ability to also load user (represented by JWT "sub" claim) from DB or external service.
In my application I want to use a JWT token, but I also want to create a custom class that will represent a principal, like UserDetials
implementation or just a new custom class.
AbstractOAuth2TokenAuthenticationToken
has a constructor, that takes token
, principal
and credentials
separately.
It would be good, if JwtAuthenticationToken
also have a constructor, that at least takes principal
separately.
If this will be added, then it will also be good if JwtAuthenticationConverter
will have an optional property
Converter<Jwt, Object> jwtPrincipalConverter;
which, if set, will be used to convert Jwt
to principal
(by loading it from DB, external service, or just by creating a more application-friendly User
object from Jwt
token) before calling new JwtAuthenticationToken
constructor.