Package io.jmix.oidc.jwt
Class JmixJwtAuthenticationConverter
java.lang.Object
io.jmix.oidc.jwt.JmixJwtAuthenticationConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,
org.springframework.security.authentication.AbstractAuthenticationToken>
public class JmixJwtAuthenticationConverter
extends Object
implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,org.springframework.security.authentication.AbstractAuthenticationToken>
Converts
Jwt
into Authentication
. We cannot use default JwtAuthenticationConverter
shipped with Spring
Security because Jmix requires an instance of UserDetails
to be
set into the SecurityContext
. That's why the current converter constructs the JmixOidcUser
and sets
it as Authentication principal.-
Field Summary
Modifier and TypeFieldDescriptionprotected OidcProperties
protected OidcUserMapper
protected String
-
Constructor Summary
ConstructorDescriptionJmixJwtAuthenticationConverter
(OidcUserMapper oidcUserMapper, OidcProperties oidcProperties) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authentication.AbstractAuthenticationToken
convert
(org.springframework.security.oauth2.jwt.Jwt jwt) void
setUsernameClaimName
(String usernameClaimName) Sets the username claim name.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
-
Field Details
-
usernameClaimName
-
oidcUserMapper
-
oidcProperties
-
-
Constructor Details
-
JmixJwtAuthenticationConverter
-
-
Method Details
-
convert
public org.springframework.security.authentication.AbstractAuthenticationToken convert(org.springframework.security.oauth2.jwt.Jwt jwt) - Specified by:
convert
in interfaceorg.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt,
org.springframework.security.authentication.AbstractAuthenticationToken>
-
setUsernameClaimName
Sets the username claim name. Defaults toJwtClaimNames.SUB
.- Parameters:
usernameClaimName
- The username claim name
-