# “部分”SSO是否可行？

**URL:** https://meta.discourse.org/t/is-partial-sso-possible/185848
**Category:** Support
**Created:** [2021年四月7日 08:25 UTC](https://meta.discourse.org/t/is-partial-sso-possible/185848 "2021-04-07T08:25:05Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2021年四月7日 09:10 UTC](https://meta.discourse.org/t/is-partial-sso-possible/185848/2 "2021-04-07T09:10:05Z")

</div>

> [@rodypl](#):
>
> 你知道当用户尝试登录或创建账户时，会看到电子邮件/密码字段，但在右侧会提供使用 Facebook、Google 等登录的选项吗？我能否直接将我网站的账户作为右侧的其中一个选项？

这取决于你对“SSO”的具体含义：

- 如果你指的是 [https://meta.discourse.org/t/discourseconnect-official-single-sign-on-for-discourse-sso/13045，那么它无法与其他登录选项同时使用。](https://meta.discourse.org/t/discourseconnect-official-single-sign-on-for-discourse-sso/13045%EF%BC%8C%E9%82%A3%E4%B9%88%E5%AE%83%E6%97%A0%E6%B3%95%E4%B8%8E%E5%85%B6%E4%BB%96%E7%99%BB%E5%BD%95%E9%80%89%E9%A1%B9%E5%90%8C%E6%97%B6%E4%BD%BF%E7%94%A8%E3%80%82)

- 如果你指的是 OAuth2、OpenID Connect 或我们的任何其他身份验证插件，那么是的，它们可以彼此同时使用，也可以与电子邮件/密码登录同时使用。

> [@rodypl](#):
>
> （就像邀请功能一样）

在这方面有个好消息——我们最近为 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 添加了邀请支持。

> <https://github.com/discourse/discourse/commit/355d51afde190b884dbb9b81ebc836a16b48d98c>
>
> This PR allows invitations to be used when the DiscourseConnect SSO is enabled f…or a site (\`enable\_discourse\_connect\`) and local logins are disabled. Previously invites could not be accepted with SSO enabled simply because we did not have the code paths to handle that logic.
> 
> The invitation methods that are supported include:
> 
> \* Inviting people to groups via email address
> \* Inviting people to topics via email address
> \* Using invitation links generated by the Invite Users UI in the /my/invited/pending route
> 
> The flow works like this:
> 
> 1. User visits an invite URL
> 2. The normal invitation validations (redemptions/expiry) happen at that point
> 3. We store the invite key in a secure session
> 4. The user clicks "Accept Invitation and Continue" (see below)
> 5. The user is redirected to /session/sso then to the SSO provider URL then back to /session/sso\_login
> 6. We retrieve the invite based on the invite key in secure session. We revalidate the invitation. We show an error to the user if it is not valid. An additional check here for invites with an email specified is to check the SSO email matches the invite email
> 7. If the invite is OK we create the user via the normal SSO methods
> 8. We redeem the invite and activate the user. We clear the invite key in secure session.
> 9. If the invite had a topic we redirect the user there, otherwise we redirect to /
> 
> Note that we decided for SSO-based invites the \`must\_approve\_users\` site setting is ignored, because the invite is a form of pre-approval, and because regular non-staff users cannot send out email invites or generally invite to the forum in this case.
> 
> Also deletes some group invite checks as per https://github.com/discourse/discourse/pull/12353

至于其他登录方式：

> <https://github.com/discourse/discourse/commit/ce04db861033c906830fd07ae98b3d0cb375c753>

这些更改已在最新版本的 Discourse 中上线。

---

_[View the full topic](https://meta.discourse.org/t/is-partial-sso-possible/185848)._
