Openid-connect插件无法获取配置

我尝试了很长时间,但似乎无法解决这个问题。我正在尝试使用 discourse-openid-connect 插件将 discourse 与 Keycloak 设置集成以进行身份验证。我正在运行 discourse-docker 版本 3.0.1。现在,当单击 OpenID Connect 登录按钮时,discourse 中会弹出此消息:“无法从身份提供者获取配置。请重试。”

我正在迁移到一个新的 discourse 设置,有趣的是,discourse 可以使用我的旧 keycloak 实例正常连接到 Keycloak 登录屏幕,但无法连接到我的新实例。这意味着以下情况应该是正确的:

  • openid-connect 插件设置绝对正确(从旧 discourse 复制而来)
  • discourse 客户端的 keycloak 设置绝对正确(从旧 discourse 复制而来)
  • 没有网络问题
  • 没有防火墙或任何阻止流量的内容

此外,我发现我可以成功地从 discourse 实例 curl keycloak 的发现文档 URL。Keycloak 版本与旧版本相同,并且 keycloak 身份验证对于位于同一 AWS 区域和可用区中的其他工具来说工作正常。下面是我尝试使用 openid-connect 登录时日志中的错误。

我已进行研究并测试了许多方法,但均无效。关于禁止 IP 的错误似乎非常笼统,我几乎可以肯定没有防火墙在阻止任何内容,尤其是我可以正常 curl 发现文档。我只能想到 discourse 可能正在从某个缓存中提取文档,或者没有命中正确的令牌 URL,但我不知道。任何帮助都将不胜感激。

Started GET "/session/csrf" for <my_ip> at 2023-02-01 18:02:24 +0000
Processing by SessionController#csrf as JSON
Completed 200 OK in 2ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 406)
Started POST "/auth/oidc" for 10.158.133.85 at 2023-02-01 18:02:24 +0000
(oidc) Setup endpoint detected, running now.
OIDC Log: Fetching discovery document from https://<keycloak_URL>.com/auth/realms/<my_realm>/.well-known/openid-configuration
OIDC Log: Fetching discovery document raised error Faraday::ConnectionFailed FinalDestination: all resolved IPs were disallowed
OIDC Log: Discovery document is

---

(oidc) Request phase initiated.
(oidc) Authentication failure! openid_connect_discovery_error: OmniAuth::OpenIDConnect::DiscoveryError, Discovery document is missing
Started GET "/auth/failure?message=openid_connect_discovery_error&strategy=oidc" for <my_ip> at 2023-02-01 18:02:24 +0000
Processing by Users::OmniauthCallbacksController#failure as HTML
  Parameters: {"message"=>"openid_connect_discovery_error", "strategy"=>"oidc"}
  Rendered users/omniauth_callbacks/failure.html.erb within layouts/no_ember (Duration: 0.1ms | Allocations: 17)
  Rendered layout layouts/no_ember.html.erb (Duration: 17.3ms | Allocations: 5113)
Completed 200 OK in 24ms (Views: 19.7ms | ActiveRecord: 0.0ms | Allocations: 6610)
1 个赞

有一个安全补丁,它不允许访问私有范围内的地址(例如 10.0.0.0/8),以防止内部网络探测。

您需要将主机名添加到“管理”->“设置”->“安全”->“允许的内部主机”中才能绕过检查。

如果插件能为您自动完成此操作就更好了。

2 个赞

太棒了!所以如果我把我的 keycloak 添加到这里,它应该就能用了吗?我是用 URL 还是 IP 地址来做这件事?

编辑:算了,这个方法奏效了。非常感谢!我花了很多时间在这上面,结果却是一个如此简单的解决方案。

2 个赞

@joshml.extra 真巧,我遇到了同样 Keycloak OIDC 集成问题,@RGJ 提供的解决方案看起来很有希望。我尝试了一下,但在我的情况中只对 IP 有效,也就是 Kubernetes pod IP。

@RGJ - DNS 能否以同样的方式工作?在我的情况下,这是一个 Nginx Ingress URL,我看到了一个证书验证失败,因为我的 Nginx Controller 上有内部 CA 签名的证书。Ingress URL 解析到一个私有 IP。

感谢这个话题!!非常感激 :slightly_smiling_face:。我几乎要放弃为我们的隔离环境寻找解决方案了。

这听起来不像您的问题是私有 IP。毕竟,如果因为私有 IP 而被阻止,您永远不会遇到证书验证失败的情况?

明白了!说得通。

谢谢你的解释。它对我来说用 IP / 主机名运行良好。

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.