如何使用 Discourse 和 Auth0 执行 SSO?

Posted

技术标签:

【中文标题】如何使用 Discourse 和 Auth0 执行 SSO?【英文标题】:How to perform SSO using Discourse and Auth0? 【发布时间】:2018-02-27 03:21:25 【问题描述】:

我正在尝试使用 Auth0 为 wordPress 和我自己的应用程序中的话语执行 SSO。下面提到了流程。

Image added here (low on rep) so cant post

用户在应用程序中输入用户名和密码,详细信息被发送到服务器,服务器使用 auth0 API 对用户进行身份验证并发回令牌。

我已经在 Discourse 中安装了来自 GitHub 的 auth0 SSO 插件 2,并且所有客户端 ID、客户端密码都添加到了插件中。

当我登录到我的应用程序时,我想知道在 Discourse 的情况下由谁执行 SSO。

对于 WordPress 使用的是以下方法。

<form *ngIf="userService.isAuthenticated()" ngNoForm action="http://xx.xx.xx.xx/index.php?auth0=implicit&client_id=xxxxxxxxxxxxxxxxxxxxxxxxx&connection=xxxxxxxxxx"
    method="post">
    <input class="hidden" type="text" id="token" name="token" value="tokenValueIsHereReturnedbyAuth0Authentication" />
    <input class="hidden" type="text" id="redirect_to" name="redirect_to" value="http://xx.xx.xx.xx/index.html" />
    <input class="btn btn-primary pull-right" type="submit" value="View" />
</form>

那么如何在话语中做类似的事情呢?

我已经尝试了以下

    https://meta.discourse.org/t/official-single-sign-on-for-discourse/13045?u=deanmarktaylor

但是我无法完成,因为我不知道是什么

https://somesite.com/sso?sso=PAYLOAD&amp;sig=SIG

PAYLOAD 和 SIG 是

更新:

我认为的有效载荷:Auth0 给我的 access_token 是有效载荷,它被编码为Base64(使用:base64encode dot org),而 SIG 是有效载荷的 HMAC-SHA256 哈希,使用 sso_secret 作为密钥和 Base64编码的有效载荷 (freeformatter dot com slash hmac-generator)

【问题讨论】:

【参考方案1】:

请查看我的博客文章,了解如何使用 Auth0 与 Discourse 集成无缝 SSO。

您基本上需要设置一个新的Auth0 Rule,它使用已开发的支持 Discourse 方式签署请求的库。使用您的客户端 ID 和客户端密码,复制并粘贴该规则的代码,并带来更好的方式来处理 SSO,而无需使用任何额外的插件。很好很容易:)

https://medium.com/leog-s-blog/discourse-sso-with-auth0-e49486d0294a

【讨论】:

以上是关于如何使用 Discourse 和 Auth0 执行 SSO?的主要内容,如果未能解决你的问题,请参考以下文章

如何在Debian 9上安装Discourse

安装 discourse 论坛

执行 Auth0/Google 联合 SSO 注销时如何将用户重定向回我的应用程序?

Discourse 如何修改用户自己的密码

Discourse 如何修改用户自己的密码

使用 Auth0 和 PHP 创建后登录用户