Keycloak-找不到指定孩子的publicKey

问题描述 投票:0回答:1

我有一个分为前端和后端服务的应用程序。前端具有公共访问权限,而后端是机密的。当我尝试授权从后端获取响应时,出现以下错误:

cache-control: no-cache, no-store, max-age=0, must-revalidate 
content-length: 0 
date: Fri, 06 Dec 2019 09:16:16 GMT 
expires: 0 
pragma: no-cache 
vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers 
www-authenticate: Bearer realm="my_realm", error="invalid_token", error_description="Didn't 
find publicKey for specified kid", Bearer realm="my_realm", error="invalid_token", 
error_description="Didn't find publicKey for specified kid" 
x-content-type-options: nosniff 
x-frame-options: DENY 
x-xss-protection: 1; mode=block 

这是我对这两种服务的配置:

Backend:
    keycloak:
        auth-server-url: http://localhost:8081/auth
        realm: my_realm
        resource: your-client-id
        ssl-required: external
        credentials.secret: your-client-secret
Frontend:
    sso: {
        url: 'http://localhost:8081/auth',
        realm: 'my_realm',
        clientId: 'your-frontend-client'
    }

我正在将keycloak 7.0.1与Spring Security一起使用。

我是否缺少任何其他配置来允许来自公共客户端的授权?

spring spring-security keycloak
1个回答
0
投票

您必须检查多项内容

  1. 您需要检查您的客户端名称在您的应用程序和密钥库中是否相同。
  2. 有时密钥库URL可能不正确,应该为httphttps://<IP ADDRESS>:PORT/auth
  3. 有时也由于证书的原因
  4. 请检查正在运行的keycloak和客户端jar的版本。

https://medium.com/@siweheee/keycloak-a-real-scenario-from-development-to-production-ce57800e3ba9

Keycloak: missing realm public key

Keycloak invalid_token Didn't find publicKey for specified kid

如果您使用的是docker环境

KeyCloak必须由同一公众从所有客户端访问出于安全原因处理。这也包括GUI服务器。它是无法通过本地IP地址与Keycloak通信,因为安全性取决于IP地址。

https://github.com/hobbit-project/platform/issues/18

© www.soinside.com 2019 - 2024. All rights reserved.