Iss 声明无效 Keycloak

pro*_*tio 4 authentication spring jwt spring-boot keycloak

我使用 keycloak 服务登录我的网络应用程序。用作具有 oauth 2.0 安全性的后端 spring。当我使用从 keycloak 获得的不记名令牌向邮递员发出请求时,它给了我一个错误 401,并且在条目旁边的答案文本中www-Authenticate它告诉我:

Bearer error="invalid_token", error_description="An error occurred while attempting to decode the Jwt: The iss claim is not valid", error_uri="https://tools.ietf.org/html/rfc6750#section-3.1"

我该如何解决这个问题?

ch4*_*4mp 5

Spring配置值必须与声明值完全相同iss。即使尾部斜杠(如果有的话)也很重要。

按照 @BenchVue 在评论中写道:在jwt.io中打开访问令牌 JWT 之一,复制 iss声明值并将其粘贴到 spring conf 中。

另一种选择是从 JWT 解码器中删除颁发者验证:jwk-set-uri在您的 conf 中提供并删除issuer-uri,但请注意,在这种情况下,令牌验证将仅使用其签名来完成。