设置 DiscourseConnect - Discourse 官方单点登录 (sso)

DiscourseConnect 是 Discourse 的核心功能,允许您配置“单点登录 (SSO)

174 个赞
Discourse SSO + normal login
Sync DiscourseConnect user data with the sync_sso route
SSO login & logout issues
Is there a "log_in" SSO API endpoint?
SSO locked me out of Discourse!
What is the SSO login URL
With SSO my user still need to hit the login button
SSO Login page not showing up
How to handle Discourse SSO when the authentication site allows users to change emails?
SSO integration & external profile sync help
"User Log out API" return success in response but user session still alive
Login to Discourse with website account details
Mobile (firebase) SSO authentication
SSO on Discourse using Atlassian Crowd
Single Sign-Out?
Discourse SSO using auth0 via URL
User Fields to validate users
Custom Login / Registration from another API
Automatically assigning users to a group
SSO and e-mail addresses having a plus sign
Automatic session management with OAuth SSO
Merging users from different forums
Advantage and disadvantage of enabling SSO
About the SSO category
Shibboleth / SAML / SSO -- Working Implementation for Higher Ed
How to generate nonce from client-side Javascript
Logout POST Request
Customized login auth plugin
Users who register on my site, register also on Discourse Vise Versa
Auto-provisioning user accounts when SSO is enabled
Categorizing and tracking users
Enable sso for my site
Disable email verification for SSO
SSO with TownNews CMS
[PAID] Setup SSO for self-hosted instance
SSO locked me out of Discourse!
Discourse Ruby API testing "Unknown attribute 'auth_token' for User
Switching out authentication for a passwordless alternative
A way for admins to edit users' external IDs
Hashing Secret + Payload for SSO
Will Discourse ask for a username if it's not provided to /session/sso_login?
Using existing RoR application for user auth / signup instead of discourse
Getting signed data from the server
SSO and changing email addresses upstream
SSO (maybe) specific issue
SSO (maybe) specific issue
Why isn't Discourse more frequently recommended as a "community platform"?
Integration with .NET MVC application for a SaaS platform
Running my own discourse image
How do I make discourse use my platform's autentication system?
Automatic addition of users to group based on email domain
Allowing people to login using accounts from other websites
Seeking Slack Login / SSO for Discourse
Smooth J/K navigation when using keyboard
SSO to Joomla site
Discourse Connect on Local instance is not working
Implementing SSO for dev environment and troubleshoot
Login with FB, google and apple only
SSO provider implementation - Admin, moderator and groups ignored?
How to divide my community into 2 parts
Using Discourse to add a forum feature to our current application?
Shared cookie SSO: Notifying frontend
User auth with website at root and Discourse in subfolder
Can I authenticate to Drupal via Discourse?
Difficulty of Tiered-access forum
Any way to not require email verification with WP as the SSO Provider?
How to enable sso on discourse?
How to auto-login user in application web view
[PAID] automatically change user email
Create apikey for user programmatically as admin
Bug when visiting same thread url
Open source will support customized provider SSO
Is there a way to get all emails of users with the API?
How can generate _forum_session and _t for an user through code/api call or without login to browser?
Show/hide forums based on the domain? (Shared forum via CNAME)
Integrate with DjangoRest and Vue.js
Connect Discourse Auth with my Django user DB?
Disable account confirm emails when creating users via API
Transforming usernames with SSO
Automatically provision accounts with external SSO provider? (skip Create New Account prompt)
Error ArgumentError in DiscourseSsoController#sso, wrong number of arguments (given 1, expected 0)
Error ArgumentError in DiscourseSsoController#sso, wrong number of arguments (given 1, expected 0)
Embed variables in footer
Need help to setup SSO without emails
Programmatically log users out of discourse
How do I remove people from putting names? I have an API system I want in there
How to detect Discourse user on Ghost Blog?
Problem in sso redirection for compose a new pre-filled topic via URL
How to make default avatars and make sure nobody changes there avatar I want to set them an avatar with my API system
How might we better structure #howto?
Is Roblox Login Possible?
Discourse login with whmcs users
2.7.0.beta4: DiscourseConnect, Topic Timer UI revamp, Login Modal UI revamp, and more
Connecting Discourse invites to Marketo emails
Auto assign member to the certain group
Connecting to an external source of avatars?
Changing avatar_url while sso_overrides_avatar is set?
SSO - User Roles or ACLs to differentiate access levels
SSO - User Roles or ACLs to differentiate access levels
Disabling email verification
SSO Isnt working for me
Could Discourse offer a StackExchange-like SSO/Federated login service?
Mandatory username & avatar generation - How can we do this?
Intergrading discoures in to a application
Configure single sign-on (SSO) with WP Discourse and DiscourseConnect
How to connect to an external database running on localhost
Automate User Creation
Login Help - Correct way to login
What happens to my current users after configuring SSO?
SSO groups without completely overriding
JumpCloud LDAP/SSO
Usernames getting modified – numeral “1” being added
Is "partial" SSO possible?
Send an invite to a user but complete their profile programmatically
Magento 2 as SSO Provider?
Discourse SSO Provider doesn't redirect to return_sso_url as user logs in with custom SSO
Force password change after login
SSO and e-mail addresses having a plus sign
Would Discourse meet all of these niche needs to be a video game community forum?
OpenID Connect and SSO
Does `sso overrides groups` work with Oauth2?
Add user to group after purchase
Shibboleth SSO with Discourse
Using discourse forum in a native app (log-in, languages)
Discourse Connect: How implementing Discourse login with an existing database?
Sync group membership with external list of email addresses
Can I use my own Login page instead of discourse's Default login dialog box?
Modify the URL of 'create your account' button to an external site
How to add a custom url text link on the login page
Can discourse delete archived posts automatically and accept registration without email?
SSO is forcibly creating the user as an admin
Onboarding 15k Trial Users/Year: Need Help Streamlining the Process
Is DiscourseConnect available for self-hosted?
Is DiscourseConnect available for self-hosted?
How to Disable Required SSO Email Activation
User avatar selection through API no longer working
Wordpress plugin not redirect to discourse login automatically
Discourse login by cookie token
Custom field in discourseconnect
Logging users in through c++ desktop application
Invite only by email from database
Is it possible to autologin discourse via iframe?
Login w/ Discourse w/o SSO?
Wordpress plugin not redirect to discourse login automatically
Discourse Hosting Limits?
DiscourseConnect always returns "Nonce is incorrect, ..."
Has anyone succeeded in using discourse as sso provider for nextcloud? Share recipe?
SSO in C# .NET App
Intergrate Discourse with keycloak
Allow my application users to login to discourse
Feature: create default user name from email's user portion when using Google OAuth2/SSO
SSO login appears to have stopped working
Is there a way to use both local login and discourseConnect?
Discourse Hosting Limits?
Changing email addresses not working as an Admin
Populating email field on login page
Problem on SSO Login
SSO Broken - The requested URL or resource could not be found
Adding Discourse to existing Ruby on Rails site
Can I use DiscourseConnect along with Discourse Native Registration?
SSO Login with Discourse
Synchronize SSO login state between Discourse and provider
Connection and discourse account creation without going on discourse
Migrate an IPB 3.1 forum to Discourse
Disable DiscourseConnect
How to use Discourse Connect (SSO) to update avatar, username, name?
Label Sets
Unable to setup discourse in my windows 10
Embed Discourse comments on another website via Javascript
How admin user re-logins after using discourse connect sso and custom domain
How to "intercept" first time SSO usages to let users confirm the SSO action and set a username?
How to create a login on my front-end application to a specific Discourse site?
Use Discourse as an identity provider (SSO, DiscourseConnect)
Connect discourse with magento?
Users allowed to see only some categories
Admin status repeatedly revoked
Plugin to integrate Shopify accounts with Discourse
How to do single sign-on with forum program?
Simple login by email via deep links containing a username
How to set language for SSO users
Want to set internal forum on our reactjs member's platform
New instructions for SSO setup? "enable discourse connect" setting is missing
Add a new user via API
Configure GitHub login for Discourse
Use SSO to auto create Discourse login/password after signed up in my SaaS
How can I change the registration URL?
How do I go about making a very customized theme?
Unable to disable SSO via SSH
Is it possible to have an automatically updating link to a user's profile picture? Such as by giving each user one "slot" for an avatar?
SSO broken after rebuild with stable v3.3.3
Using Discourse Connect with a mobile app
Disable DiscourseConnect
Missing anchor links in certain TOC topics?
Integration into custom auth system where emails are not unique?
WP-Discourse not connected and admin email not recognized
How to disable SMTP during installation?
Auto Login to my Discourse site / subdomain
How to Disable activation_reminder email sending?
Extending header buttons
Auth via Discourse Forum
🧩 How to Build an Android App User Community with Discourse? [HeyApks Project]
Postgres doesn't seem to be running when running Discourse locally using Docker
Discourse sso login redirect to localhost:3000, not 4200 (running via docker)
Cross-Discourse Quoting
Is it Possible to Send Encrypted Email and Password in the Authentication Flow?
Nutzung von Nextcloud aus Discourse heraus
Inherited forum with old Discourse Connect Config and Looking for Some Guidance
Merging user accounts
Understanding PII storage in Discourse
REQUEST: Highly Effective Age Assurance (OneID Phone No. Age Verification) Integration
Intergrate Discourse with keycloak
Auto-sign-in with the OpenId Connect Plugin and AWS Cognito
How can I configure Single Sign On for our App to the Discourse Community Forum
Auto-assign random, anonymous usernames
Communities using discourse SSO for their in-app community experience
Login to Discourse with custom Oauth2 provider
Can I log into multiple instances of discourse simultaneously?
Upgraded last night and login button no longer works
SSO with Roles translating to Groups
Redirect login possible?
How to disable SSO via SSH
Connect Multiple WP Sites To 1 Discourse Installation?
What is the procedure to obtain CAS between my website and my discourse instance?
Problem logging in using SSO plugin
PAID: Create Open Source SSO plugin to auth with Wild Apricot
Trouble connecting drupal and discourse
About the idea: IDENTITY = EMAIL
About the idea: IDENTITY = EMAIL
Consequences of not validating email addresses
SSO and Restricted Groups
Questions about Discourse on Digital Ocean
Require users to join at least one group at sign-up
Use the same user database and login credentials in multiple discourse instances
How to connect my (existing) User Database?
User group sync with drupal
Options with SSO with another custom application
Issues in Integrating SSO in Discourse
How to implement Discourse with an already built Rails project
Updating SSO documentation
Configuring SSO to Work With SocialEngine
Updating SSO documentation
Discourse view file update does not reflect in browser
Discourse view file update does not reflect in browser
Trying to set up SSO
Discourse doesn't re-verify an address changed by SSO
Discourse doesn't re-verify an address changed by SSO
SSO and Discourse Consulting
Changing the unique key to identify users
Setting the user title(group?) based on the information that is coming from the sso payload
Advice needed for tailoring Discourse to my organisation
Primary and Discourse Site Integrations
Automatic Table of Contents generation
Questions Regarding Account Authentication Methods
Redirect all users who click on domain.com/signup to a different page
Poll Result Breakdown
Cant update email via API - invalid_access error
Disabling all emails except those registration related?
Can't get avatar overrides to work over SSO
Conflicting email addresses, giving admins more power to resolve issues
Which Discourse hosting tier should I choose?
New users via API if allow new unchecked
How to change login settings without being logged in?
Data explorer query to list the longest "estimated read time" topics?
Create user in discourse by redirecting from another site
HMAC-256 example on Official SSO page
Add links to meta.discourse.org instructions inside admin
How to configure the SSO Authorization URL via config (without using the admin panel)
TeamAndro exploring a migration from phpBB
DiscourseConnect payload hash encoding mismatch
Disabling SSO in development environment
Getting signed data from the server
Getting signed data from the server

您好,我很难找到任何信息,但它使用的是什么协议?假设是oauth2?参数似乎不匹配,并且我收到提供商的错误,该提供商似乎接受 sso= 参数?救命!\n\n谢谢

DiscourseConnect 是 Discourse 的 SSO 实现。它不使用标准协议。

如果您不介意查看 PHP 代码,这里有一个示例实现:https://github.com/discourse/wp-discourse/blob/main/lib/sso-provider/discourse-sso.php。

是的,那行不通。如果您有想要用于验证用户的 OAuth2 提供商,请查看 Discourse OAuth2 Basic 插件。

1 个赞

感谢 @simon。PHP 代码也是一个提供者,而不是消费者吗?我还看到了一个 OIDC 提供者,它也可能起作用,还有一个插件区域中的“中间人”提供者。

如果 SSO 提供者是非标准的,那么它打算为谁/什么服务,如果它不能与其他提供者很好地协同工作的话?

再次感谢!

我链接的代码是用于将 WordPress 作为 Discourse 的身份验证提供者。

WordPress 插件还允许将 WordPress 用作 DiscourseConnect 客户端:https://github.com/discourse/wp-discourse/tree/main/lib/sso-client。

我不确定在 Discourse 中添加自定义 SSO 实现的动机是什么。我猜是有商业原因的。

它提供的一个好处是允许将外部站点与 Discourse 紧密集成。例如,此处列出的所有用户属性都可以在身份验证过程中与 Discourse 同步:discourse/lib/discourse_connect_base.rb at 7b89fdead98606d4f47ceb0a1d240d0f6e5f589e · discourse/discourse · GitHub

它还允许将未配置为 OAuth2 或 OpenID Connect 提供者的站点用于对 Discourse 上的用户进行身份验证。

缺点是它需要在身份验证提供者站点上添加一些自定义代码。

1 个赞

您好,我想了解一下在提供 SSO 的外部网站上不验证电子邮件地址会存在哪些问题。仅仅是这样会助长自动垃圾邮件吗?还是有其他需要考虑的因素?如果外部网站不进行电子邮件验证,为什么不建议 Discourse 来处理电子邮件验证?

感谢您提供的任何额外见解。

据我所知,最糟糕的情况需要满足以下条件:

  • 电子邮件地址未在外部网站上进行验证
  • SSO 负载中未设置 require_activation=true
  • Discourse 站点上已存在没有关联 SingleSignOnRecord 的帐户(帐户所有者从未通过 SSO 登录过 Discourse)

在这种情况下,有人可以在外部网站上使用从未通过 SSO 登录过的 Discourse 用户的电子邮件地址注册。这将允许来自外部网站的未经验证的帐户接管使用相同电子邮件地址的 Discourse 帐户。如果这是 Discourse 上的管理员帐户,那将尤其令人担忧。

如果外部网站未处理电子邮件验证,确实建议 Discourse 处理电子邮件验证:

不过,在外部网站上处理电子邮件验证有几个原因更好:

  • 强制用户接收来自 Discourse 的确认电子邮件会在用户首次尝试登录 Discourse 时增加一些摩擦。(但实际上,这种摩擦必须发生在某个地方——要么在 Discourse 端,要么在外部网站端。)
  • 如果 SSO 负载中的 require_activation 设置为 true,Discourse 将不会根据电子邮件地址将现有的 Discourse 帐户与外部登录匹配。如果您在 DiscourseConnect 启用后,某些帐户已通过用户名/密码注册创建,那么这将是一个问题。如果您出于任何原因需要删除 Discourse 上的 SingleSignOnRecord 条目,那也将是一个问题。当用户尝试重新登录 Discourse 时,Discourse 不会自动创建新的 SingleSignOnRecord 条目。
4 个赞

谢谢,@simon - 这非常有帮助!

您好,我有一个关于 SSO payload 中 groups 字段的问题。

自动用户组(例如管理员、版主和信任等级)也会被覆盖吗?还是会保留?

不会!假设该设置的描述是正确的,它只会影响手动用户组。

你知道吗……我在描述中没有看到“手动”这个词。听起来很有希望,符合我的用例,我会试试看,然后回来汇报。

1 个赞

当我读到这里时,我以为我应该直接从base64编码的载荷生成签名。我没有意识到你需要从UTF-8字节生成它。能否澄清一下?

我一直在使用 DiscourseConnect - 文档很棒,谢谢。
不过我遇到了一些障碍,希望得到一些帮助/澄清。

我们希望用户能够使用他们的 Discourse 登录来登录 Wordpress(这工作正常 :slight_smile: ) - 然而。

  • 是否可以通过 Discourse 注册来创建 Wordpress 用户(当用户创建 Discourse 用户帐户时,它会自动为他们创建 wordpress 帐户/配置文件,以便他们可以登录 wordpress)

  • 是否可以同步 Workpress 用户组和 Discourse 组。
    如果用户同时拥有 Wordpress 和 Discourse 用户帐户,DiscourseConnect 能够将它们关联起来 - 但它不会给 wordpress 帐户与其同名的 Discourse 组的用户组,反之亦然(如果组名称不同怎么办 - 我该如何告诉 DiscourseConnect 在用户拥有名为“Group for Testing Things”的 Discourse 组时,为他们分配名为“Testing Group”的用户组?)

我错过了什么?

我不知道答案,但是……

要小心。这在某种程度上是非法的,而且被广泛认为是不好的做法(当然,网站所有者除外 :smirking_face:),因为这会在用户不知情或未经同意的情况下发生,同时数据也会被转移到其他地方。

当然,这在某种程度上处于灰色地带,基本上,例如,谷歌就是这样做的。

但是……为什么?在WordPress端仅限于Discourse SSO登录,并将用户重定向到Discourse进行账户创建,仅此而已。但据我所知,你无法开箱即用地自动同步用户账户。而且你为什么要这样做,因为有了SSO,当用户需要时就会发生。

在我们的场景中(作为一个会员组织)

  • WordPress 用于管理订阅、在 WordPress 商店购买商品,我们使用用户组来管理会员在组织内的权限
  • Discourse 是我们的论坛/在线社区,我们使用群组来控制用户可以访问 Discourse 的哪些区域)

目前,新会员需要设置一个 WordPress 账户(并设置他们的订阅等),同时还需要设置一个 Discourse 账户,并且用户组-Discourse 群组是手动管理/同步的。

我正在寻找一个解决方案,让新用户只需设置一次即可创建两个账户,并且用户组-Discourse 群组能够自动同步——我相信我可以通过 API 等方式解决群组同步问题。我试图解决/避免的是多用户账户设置问题。

听起来您正在使用 Discourse 作为 WordPress 的 SSO 提供商。该方法在此处进行了概述:使用 Discourse 作为身份提供商 (SSO, DiscourseConnect)。Discourse WordPress 插件提供了将 WordPress 作为 Discourse 的 SSO 提供商,或将 Discourse 作为 WordPress 的身份提供商的选项。对这两种方法使用相同的名称会导致一些混淆。

在这种情况下,我倾向于使用 WordPress 作为身份提供商。通过这种方法,用户将在您的 WordPress 网站上创建账户,然后使用他们的 WordPress 凭据登录 Discourse。需要注意的一点是,这意味着用户只能通过 WordPress 登录 Discourse,而无法在没有 WordPress 账户的情况下创建 Discourse 账户。我认为这是将 Discourse 与 WordPress 会员网站集成时的合适设置。

当 WordPress 被用作 Discourse 的身份提供商时,有几个实用函数可用于根据用户在 WordPress 上的活动来设置用户的 Discourse 群组会员资格。这些函数在此处进行了概述:使用 WP Discourse SSO 管理 Discourse 中的群组会员资格

回到您最初的问题:

我有一段时间没有查看 WordPress 插件的 DiscourseConnect 客户端代码了,但我认为您所询问的功能或多或少是该代码的预期工作方式。如果用户拥有 Discourse 账户,他们只需点击 WordPress 上的“通过 Discourse 登录”链接,就会为他们创建一个账户。

在使用 WordPress 作为 DiscourseConnect 客户端时,这在技术上是可行的,但除非有什么变化,否则您将无法使用我链接到的文档中概述的 add_user_to_discourse_groupremove_user_from_discourse_group 方法。您需要做一些事情,例如设置一个 Discourse Webhook,在用户被添加到 Discourse 群组时触发,然后在 WordPress 上添加一些代码来处理该 Webhook。要将群组从 WordPress 同步到 Discourse,当 WordPress 上发生更改时,您需要向 Discourse 发出 API 调用来更新用户的群组。因此,如果您使用 WordPress 作为 DiscourseConnect 提供商,那么一些相对容易实现的事情,如果使用 WordPress 作为 DiscourseConnect 客户端,可能会有些复杂。

1 个赞

除非使用自定义登录,因为通常在使用 WooCommerce/memberships/LLM 时会出现这种情况,并且默认情况下不会强制只使用 Discourse SSO 作为提供商,这需要一些自定义工作。

有几个可能的问题,一个与缓存有关,另一个与某些插件添加的登录重定向有关。遇到这些问题的任何人都可以到 Support > WordPress 类别中提问。这些问题通常很容易解决。

我完全忘了回复:确实,它的作用与描述的完全一样,只影响手动群组。

你好 @simon

我认为我真的需要一些关于我的 SSO 功能 POC 探索中的 404 响应的帮助。我为这个问题花了一整天的时间,但仍然无法弄清楚问题所在。我能够:

  1. 启用 discourse_connect
  2. 将 discourse_connect_url 设置为 https:/ /localhost:4200/login
  3. discourse-connect secret:20’s (1) 1111111111111111111 保持简单

然后在我的 Angular 应用的登录页面,我通过以下代码发送了这个请求:


但我收到了 404 未找到的响应。

根据我的理解,在向 admin/users/sync_sso 端点发送 POST 请求时,如果用户不存在于 discourse 中,它应该根据 user_id 和 email 创建一个新用户,然后返回的结果应该是一个用户对象,而不是一个状态码为 404 的空对象。
我也检查了日志,它没有提供任何与此失败响应相关的​​信息。

提前感谢!