# Rocket.Chat Single Sign-On (SSO) + 嵌入插件

**URL:** https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450
**Category:** Plugin
**Tags:** unmaintained
**Created:** [2021年八月6日 16:18 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450 "2021-08-06T16:18:46Z")
**Posts on this page:** 12
**Page:** 3

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2021年十一月6日 16:55 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/43 "2021-11-06T16:55:54Z")

</div>

> [@mangojumbo](#):
>
> 有没有办法将嵌入式聊天设置为主页而不是默认频道打开？

我已将此功能添加到插件中。只需将其更新到最新版本，然后将 `discourse rocketchat default channel` 设置设置为空。

---

<div class="post-metadata">

### Author: ![mangojumbo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mangojumbo](https://meta.discourse.org/u/mangojumbo)
#### Post date: [2021年十一月6日 17:15 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/44 "2021-11-06T17:15:03Z")

</div>

太棒了！我下周回到住处后会立即更新并进行测试。\n再次感谢！

---

<div class="post-metadata">

### Author: ![Mr.X\_Mr.X](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mr.x_mr.x/32/126610_2.png) [@Mr.X\_Mr.X](https://meta.discourse.org/u/Mr.X_Mr.X)
#### Post date: [2021年十一月8日 13:42 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/45 "2021-11-08T13:42:08Z")

</div>

此插件在我这边给所有用户都带来了一些问题：

点击“登录 CAS”按钮后，会弹出一个包含以下链接的窗口：

rocketchat.domain/\_cas/BJZ6ef4aSDdeEf5C?ticket=c27a3525gg4ggff7f859f4a3a37c

（为安全起见，我随机化了粘贴令牌的某些部分）。

这是一个空白页面，不会自动关闭，并且除非用户关闭该窗口，否则登录不会继续。一旦用户关闭此弹出窗口，登录就会继续，之后一切正常。每次有人尝试登录时都会发生这种情况，即使是以前登录过的用户也是如此。

---

<div class="post-metadata">

### Author: ![Mr.X\_Mr.X](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mr.x_mr.x/32/126610_2.png) [@Mr.X\_Mr.X](https://meta.discourse.org/u/Mr.X_Mr.X)
#### Post date: [2021年十一月8日 13:43 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/46 "2021-11-08T13:43:49Z")

</div>

> [@mangojumbo](#):
>
> > [@RGJ](#):
> >
> > 将此脚本设置为Rocket.Chat中的“未登录用户自定义脚本”（请确保在第二行替换为您论坛的名称）。注意：我最近没有测试过。我不确定如果它不起作用我是否能帮到您。
> 
> 非常感谢您提供的信息丰富的回复。  
> 我之前在[此处](https://github.com/RocketChat/Rocket.Chat/issues/2327)看到您发布的脚本，但我认为它只适用于CAS身份验证，而不适用于SSO。我将尝试一下，并检查浏览器是否不会阻止隐藏窗口。
> 
> > [@RGJ](#):
> >
> > 我将在几周内研究一下。我会保持Github issue的开放状态以提醒自己。
> 
> 太感谢了！在我看来，能够在嵌入式聊天窗口中默认显示主页将是一个非常有趣的补充。如果您有时间投入其中，我期待着它最终被实现。感谢您考虑添加此选项。

您能让自动重定向生效吗？我尝试了@RGJ的自定义脚本以及这个[CAS Plugin: Add direct login redirect for a CAS-enabled RC instance · Issue #2327 · RocketChat/Rocket.Chat · GitHub](https://github.com/RocketChat/Rocket.Chat/issues/2327#issuecomment-639355281%EF%BC%8C%E4%BD%86%E9%83%BD%E6%B2%A1%E6%9C%89%E6%88%90%E5%8A%9F%E3%80%82)

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2021年十一月8日 13:47 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/47 "2021-11-08T13:47:40Z")

</div>

> [@Mr.X\_Mr.X](#):
>
> 它是一个空白页面，不会自行关闭，并且除非用户关闭窗口，否则登录不会继续。

那里有一个内联脚本来关闭该窗口，但它可能未在您的 CSP 中列入白名单。  
作为一种快速修复方法，在 Rocket.Chat 端，转到“管理” - “常规”并禁用“启用内容安全策略”。请注意，这可能会使您的站点面临安全风险。您应该解决根本问题。

请将此处的所有报告和请求限制在与插件相关的问题上。在 Rocket.Chat 或您的 Rocket.Chat 主机名内发生的任何错误，都应视为 Rocket.Chat 问题，而不是 Discourse 或插件的问题。

---

<div class="post-metadata">

### Author: ![mangojumbo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mangojumbo](https://meta.discourse.org/u/mangojumbo)
#### Post date: [2021年十一月10日 16:46 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/48 "2021-11-10T16:46:05Z")

</div>

> [@RGJ](#):
>
> 我已将此功能添加到插件中。只需将其更新到最新版本，然后将 `discourse rocketchat default channel` 设置设置为空。

我测试了新版本，效果很棒！非常感谢！

---

<div class="post-metadata">

### Author: ![mangojumbo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mangojumbo](https://meta.discourse.org/u/mangojumbo)
#### Post date: [2021年十一月10日 16:52 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/49 "2021-11-10T16:52:53Z")

</div>

> [@RGJ](#):
>
> > [@Mr.X\_Mr.X](#):
> >
> > it’s a blank page that doesn’t close itself and the login is not proceeding unless the user closes the window.
> 
> There is an inline script there to close that window which is probably not being whitelisted in your CSP.  
> As a quick fix, on Rocket.Chat side, go to Admin - General and disable “Enable Content-Security-Policy”. Please note that this might open up your site to security issues. You should address the underlying problem.
> 
> Please limit all reports and requests here to issues concerning the plugin. Any error that is happening within Rocket.Chat or on your Rocket.Chat hostname, should be considered a Rocket.Chat issue and not an issue of Discourse or the plugin.

@Mr.X_Mr.X ，我之前也遇到过同样的问题，就是那个空白窗口关不掉，我当时以为是我的CAS配置有什么问题。  
我禁用了 Content-Security-Policy，现在空白窗口可以自己关闭了。谢谢 Richard 解释了问题所在！  
不过，我还是想知道如何添加例外并启用这个安全功能。

@RGJ 抱歉打扰，但这个问题不应该和你的插件有关吗？内联脚本是嵌入在你的插件里的吗？还是你说的是在 Rocket.Chat 端手动添加的内联脚本？  
再次感谢。

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2021年十一月10日 17:14 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/50 "2021-11-10T17:14:56Z")

</div>

> [@mangojumbo](#):
>
> 这个问题是不是和你的插件有关？内联脚本是否嵌入在你的插件中？

不，它在 Rocket.Chat 中的 CAS 弹出窗口中（您可以看到弹出窗口的 URL 是在 RC 主机名上）。

---

<div class="post-metadata">

### Author: ![mangojumbo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mangojumbo](https://meta.discourse.org/u/mangojumbo)
#### Post date: [2021年十一月10日 17:17 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/51 "2021-11-10T17:17:49Z")

</div>

好的，抱歉，我保证这是最后一个问题：  
那么，您建议为 Rocket.Chat CSP 添加白名单（可能添加 Discourse 域，我猜）吗？

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2021年十一月10日 17:24 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/52 "2021-11-10T17:24:12Z")

</div>

> [@mangojumbo](#):
>
> 您会建议向 Rocket.Chat CSP 添加白名单（可能添加 Discourse 域名）吗？

不，这 100% 是 Rocket.Chat 端的问题。Rocket.Chat 的 Javascript 正在尝试关闭一个 Rocket.Chat 弹出窗口，但根据 Rocket.Chat CSP 的规定，它不允许这样做。  
它发生在 Rocket.Chat 中的所有登录弹出窗口，如 CAS 或 OAuth2。如果您搜索一下，您也会找到其他报告。

---

<div class="post-metadata">

### Author: ![mangojumbo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@mangojumbo](https://meta.discourse.org/u/mangojumbo)
#### Post date: [2021年十一月10日 17:29 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/53 "2021-11-10T17:29:28Z")

</div>

太好了。再次非常感谢您的解释！

---

<div class="post-metadata">

### Author: ![Mark\_Schmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mark_schmucker/32/124810_2.png) [@Mark\_Schmucker](https://meta.discourse.org/u/Mark_Schmucker)
#### Post date: [2021年十一月11日 02:55 UTC](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450/54 "2021-11-11T02:55:36Z")

</div>

是否有办法设置特定主题的频道？这样，如果插件显示在此主题上，频道将自动设置为“rocket-chat-sso-embed-plugin-for-discourse”？

[上一頁](https://meta.discourse.org/t/rocket-chat-sso-embed-plugin/199450.md?page=2)
