Class IamJwtAuthenticationConverter
java.lang.Object
com.chaosguide.iam.vertex.jwt.IamJwtAuthenticationConverter
- All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.authentication.AbstractAuthenticationToken>
public class IamJwtAuthenticationConverter
extends Object
implements org.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.authentication.AbstractAuthenticationToken>
把 IAM 签发的
Jwt 转成 Spring Security 使用的 JwtAuthenticationToken。
最终 authorities 来自两部分:
- JWT 的
rolesclaim 转成ROLE_<role>。 - 通过
PermissionResolver.resolve(String, Set)解析出的resource:action权限。
注意:这里不会读取、信任或合并 JWT 里的 permissions claim。权限必须运行时解析,避免 token
过大以及权限撤销延迟。
-
Constructor Summary
ConstructorsConstructorDescriptionIamJwtAuthenticationConverter(PermissionResolver resolver, IamSecurityProperties props) -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.security.authentication.AbstractAuthenticationTokenconvert(org.springframework.security.oauth2.jwt.Jwt jwt) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.convert.converter.Converter
andThen
-
Constructor Details
-
IamJwtAuthenticationConverter
-
-
Method Details
-
convert
public org.springframework.security.authentication.AbstractAuthenticationToken convert(org.springframework.security.oauth2.jwt.Jwt jwt) - Specified by:
convertin interfaceorg.springframework.core.convert.converter.Converter<org.springframework.security.oauth2.jwt.Jwt, org.springframework.security.authentication.AbstractAuthenticationToken>
-