我在一个Spring Boot微服务中遇到了一个关于Spring Security中令牌解密部分的问题。基本上发生了以下问题:在@AuthenticationPrincipal Jwt jwt上调用getSubject()方法时发生以下错误
Caused by: java.lang.IllegalStateException: The Issuer "https://ids-for-spid.aqp.it:443/oauth2/token" provided in the configuration did not match the requested issuer "https://clidens1.aqp.it:9443/oauth2/token"
我猜想这是由于以下条件造成的:在一个众所周知的文件中,有一个发行者的url基础与传递给库的url基础不同(我猜是因为有一个代理或网关),我该如何解决以下问题?
Specifically, the url to access the well-known file is the following https://clidens1.aqp.it:9443/oauth2/token/.well-known/openid-configuration ed and inside there is the following issuer https://ids-for-spid.aqp.it/oauth2/token , which differs from the base url clidens1.aqp.it on which I have the only accessibility.
1条答案
按热度按时间cbjzeqam1#
在JWT验证过程中,将根据conf中的发布者URI检查标记
iss
声明。它必须完全匹配(即使尾部有斜杠也很重要)。对于令牌验证,还需要授权服务器公钥。它是使用JWK-set URI提取的,通常可以在OIDC配置中找到,它本身通常可以从
iss
声明值推导出的位置获得。如果在
iss
声明中声明的主机无法从resource-server访问,您是否也尝试过设置JWK-set URI属性?如果任何人都无法访问
iss
声明中的此主机名,您是否尝试过配置授权服务器以更改iss
声明的值?在Keycloak中设置
hostname
配置属性可以解决您的问题,但是您显然使用了另一个授权服务器。