资源服务器获取用户信息,资源服务器如何通过jwks_uri解密 token,转换为用户信息…

  • Post author:
  • Post category:其他


默认的 oidc client有个校验器,可以校验token,但是无法做到转换为用户信息吧,这个校验 和转换器就没有关系对吧。

“`

public class OIDCTokenVerifier {

private static final Logger LOG = LoggerFactory.getLogger(OIDCTokenVerifier.class);

private final RPHolder rpHolder;

private final String token;

public OIDCTokenVerifier(RPHolder rpHolder, String token) {

this.rpHolder = rpHolder;

this.token = token;

}

public Map verify() {

VerificationKeyResolver verificationKeyResolver = new HttpsJwksVerificationKeyResolver(new HttpsJwks(rpHolder.getDiscoveryEndpointInfo().getJwks_uri()));

JwtConsumer consumer = new JwtConsumerBuilder()

.setVerificationKeyResolver(verificationKeyResolver)

//此处有许可项可配置进行校验,请根据实际需要配置

//更多帮助可访问 https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples

//{“user_name