通过外部 SSO 提供商自动配置账户?(跳过“创建新账户”提示)

I’ve just setup a Discourse instance and added the discourse-openid-connect to it, connecting Keycloak as the OIDC provider.

After following the 3 conditions stated here with a recent update, I get the behaviour to authenticate via Keycloak, or if already logged in, clicking the “Login” button will prompt me to “Create New Account” with the fields filled in sourced from Keycloak info on the user.

Is there a way to skip this part requiring an additional step from the user? These are fields are naturally already populated from Keycloak, so there shouldn’t be a need for the user to modify them specifically for Discourse.

The account creation should be handled implicitly, similar to how Grafana is able to do it? I am aiming for each service provided by the community to support this seamless experience, that the original community account that is signed-up is all they have to deal with.

This might not make sense if you’re thinking about external auth such as Google / Facebook / Github / etc. A user can register their community account via Keycloak with one of those, but Keycloak itself which is only used internally is what is intended to work with all the individual services, so implicit/automated consent and sign-up is desirable.

我是 Discourse 新手,我的 SSO OAuth2 提供商已设置并正常运行。新用户首次访问并登录 Discourse 时会看到提示页面。如何简化此流程,让用户自动创建账户?该页面中填充的值是正确的,且只需操作一次。有什么方法可以移除该页面,从而简化社区用户的账户创建流程?

目前这还无法实现。当用户首次创建账户时,他们需要在注册表单上点击“创建新账户”按钮。

您所期望的行为类似于 Discourse 的 SSO 实现。在这种情况下,账户会在后台创建,用户无需填写注册表单。看起来为 OAuth2 登录实现类似功能是可行的,但可能存在 OAuth2 提供商传递的信息不足以创建账户的情况。

自从我在这里发帖后,我没花太多时间在这上面,但我最终改用 Discourse 的 SSO 功能,搭配我偶然发现的一个用于 OpenID-Connect 的桥接服务。那是一个带有 Docker 容器的 Python 服务,让我用 docker-compose 部署变得更加容易。

所以,Keycloak 负责提供已注册并登录的账户,用户访问 Discourse 时,会根据桥接服务提供的信息完成注册(我记得是这样)。毕竟已经有一段时间没处理这个了,但据我所知,这比 Discourse 原生的 OAuth/OpenID-Connect 支持流程要稍好一些(至少当时是这样,不确定后来是否有改进)。

无论如何,账户信息无法按预期同步。用户需要退出 Discourse 再重新登录,同步才会发生。而且即便如此,我认为有些内容(比如群组/角色之类的)也无法从 SSO 提供商同步到 Discourse,其中存在一些陷阱。

我认为,要实现真正的同步,你需要检测提供商处用户信息的更新,并通过 Discourse 的 API 触发更新。否则,可能会出现信息重复或不同步的情况,给用户造成困扰。


所以,呃,如果你目前使用的 OAuth2 SSO 集成并非 Discourse 原生 SSO 功能(该功能通常需要 SSO 桥接),而是那个插件替代方案,那么切换到带有 SSO 桥接的非插件版本,应该就能获得你想要的体验(我记得是这样)。

我也希望能避免在使用 OAuth2 时出现“创建新账户”窗口。是否可以在某处添加一个选项,以便在字段齐全时跳过该窗口?

我刚刚添加了一些新的站点设置,这将有助于解决这个问题。要跳过“创建新账户”界面,请启用 sso_overrides_usernamesso_overrides_emailsso_overrides_name

若要完全跳过弹出窗口,请启用 external_auth_skip_create_confirm

如果您没有看到该选项,请确保您使用的是最新版本的 tests-passed。

external_auth_skip_create_confirm 已启用

我们遇到了一个问题:

  1. 我们的 Discourse 中已存在账号 test__EMAIL__。
  2. 如果我使用 OpenID 登录,用户名为 test,邮箱为 test__EMAIL__,
    系统会弹出“新建账号”窗口,要求我输入新用户名 test1 和邮箱 test__EMAIL__。

目前无法将旧账号与 OpenID 关联。

您的 OpenID Connect 提供商是否验证用户邮箱?只有当邮箱经过验证且 verified 布尔值正确设置时,我们才能“信任”来自 OIDC 的邮箱地址。

无 OID 提供商 - Keycloak 结合 LDAP 用户联合
我们找到了解决方法:旧用户可在用户设置界面中连接 OpenID。

@david 我们使用的是 2.5.2 稳定版,该选项并不存在……能否将此选项迁移到稳定分支?我们需要它,但在生产环境中除了稳定分支外,我们不使用任何其他版本。

恐怕不行,我们不会将新功能反向移植到稳定分支。请密切关注 #releases,以获取下一个稳定版本发布时间的信息。

@david
目前还不清楚下一个稳定版本具体是关于什么的……是次要版本 2.5.3?还是版本 2.6.0?

下一个主要版本将是 2.6.0。次要版本(2.5.x)将仅用于安全修复。

@david 感谢!现在清楚了。2.6.0 版本今年会发布吗?)))

我们还没有确认具体日期,但今年确实有很大的可能性 :slight_smile: