Discourse OAuth2 基础

我找到了问题:Header 没有设置为“Content-Type: application/json”。我看到 @qlands 上面的问题也是一样的。

对我来说,唯一剩下的问题和 @nodomain 的一样:账户创建成功了,但头像没有包含在内。示例响应:

Body: {
  "access_token":"...",
  "token_type":"bearer",
  "expires_in":"3600",
  "scope":"profile",
  "profile" : {
    "id":1234,
    "email": "...",
    "name": "...",
    "picture": "https://somedomain.com/somevalidpicture.jpg"
  }
}

并且它被正确解析了,因为它出现在以下日志中:

OAuth2 Debugging: after_authenticate response:

creds: {"token"=>"...", "expires_at"=>1702053692, "expires"=>true}
uid: 1234
info: {"email"=>"...", "name"=>"...", "avatar"=>"https://somedomain.com/somevalidpicture.jpg"}
extra: {}

我检查了图片地址是正确的,并且尺寸是 300x300。

关于这个问题有什么想法吗?

编辑:有人刚创建了一个账户,它从 Gravatar 获取了图片。也许 JSON 中的有效图片被 Gravatar 返回的空白结果覆盖了?

Authentik 作为 OAuth 提供商

我目前正在尝试使用 Authentik,想问问是否有人在 Discourse 中使用过它?

不幸的是,我还没有找到关于 Discourse 的官方支持文档。

有很多设置需要调整 :smiley:

Portainer 的 OAuth 实现要简单得多。

Portainer,仅供参考:

1 个赞

你好吗?我想在 Discourse 和 Ghost 中实现 SSO w/Authentik,但我的项目目前处于待定状态。

任何建议都将不胜感激 :slight_smile:

1 个赞

有人遇到过 SSO 位于内部网络,而 Discourse 尝试使用内部 IP 地址访问 SSO 站点时变得无法访问的问题吗?

tail -f production.log

(oauth2_basic) Setup endpoint detected, running now.
(oauth2_basic) Request phase initiated.
Started POST "/presence/update" for 10.10.10.10 at 2024-06-15 18:19:44 +0000
Processing by PresenceController#update as */*
  Parameters: {"client_id"=>"xxx", "present_channels"=>["/chat-user/core/1"]}
Completed 200 OK in 26ms (Views: 0.2ms | ActiveRecord: 0.0ms | Allocations: 1895)
Started GET "/auth/oauth2_basic/callback?code=xxxx&state=xxxx" for 10.10.10.10 at 2024-06-15 18:19:49 +0000
(oauth2_basic) Setup endpoint detected, running now.
(oauth2_basic) Callback phase initiated.
OAuth2::ConnectionError (FinalDestination: all resolved IPs were disallowed)
lib/final_destination/ssrf_detector.rb:105:in `lookup_and_filter_ips'
lib/final_destination/http.rb:15:in `connect'
lib/middleware/omniauth_bypass_middleware.rb:43:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
lib/middleware/anonymous_cache.rb:391:in `call'
lib/middleware/csp_script_nonce_injector.rb:12:in `call'
config/initializers/008-rack-cors.rb:14:in `call'
config/initializers/100-quiet_logger.rb:20:in `call'
config/initializers/100-silence_logger.rb:29:in `call'
lib/middleware/enforce_hostname.rb:24:in `call'
lib/middleware/request_tracker.rb:289:in `call'

网页错误

糟糕
运行此讨论论坛的软件遇到了意外问题。很抱歉给您带来不便。

错误详情已记录,并已生成自动通知。我们会进行查看。

无需进一步操作。但是,如果错误状况持续存在,您可以通过在站点的反馈类别中发布讨论主题来提供更多详细信息,包括重现错误的步骤。

我检查了防火墙日志,但没有发现任何阻止记录!此外,Discourse 和 SSO 都位于内部网络,因此不应该有任何防火墙阻止或请求拦截问题!

但是,当我将 SSO 站点的 IP 地址指向外部公共网络时,它又恢复正常了!

这是插件中的错误还是我这边的配置问题?

您可以将内部 SSO 站点的 वापरा名添加到“allowed_internal_hosts”站点设置中。然后 Discourse 将能够连接到它。

如何将 URL 中的 client_id 更改为 appid
我的服务器不支持 URL 中的 client_id,只支持 appid。
我必须修改插件。
请帮帮我。

一年后,您仍在帮助处理此帖子!谢谢!!Authentik 现在对我来说很好用。

3 个赞

您好,我正在使用 Zalo 的 Oauth2,但遇到了附件中的问题。有人知道原因吗?

我配置的回调 URL 是:https://sphere.daviteq.com/auth/basic_oauth2/callback

有人能分享一个 authentik 配置吗?我相当确定我已经正确设置了一切,但仍然收到 (oauth2_basic) Authentication failure! Timeout::Error: Faraday::TimeoutError, Timeout::Error

1 个赞

:partying_face: 此插件现已作为 Bundling more popular plugins with Discourse core 的一部分,与 Discourse 核心捆绑在一起。如果您是自托管用户并使用了此插件,则需要在下次升级前将其从 app.yml 中移除。

交叉引用

1 个赞