# 升级后出现 SAML 错误

**URL:** https://meta.discourse.org/t/saml-error-after-upgrade/151589
**Category:** Support
**Created:** [2020年五月15日 10:00 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589 "2020-05-15T10:00:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [2020年五月15日 10:00 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589/1 "2020-05-15T10:00:36Z")

</div>

继续讨论 [PostgreSQL 12 更新](https://meta.discourse.org/t/postgresql-12-update/151236)：

升级后，我在网站上收到了一个之前未出现的 SAML 错误：

`抱歉，授权您的账户时发生错误。请重试。`

错误日志显示：

`(saml) 认证失败！invalid_ticket: OneLogin::RubySaml::ValidationError, http://www.example.com 不是此响应有效的受众 - 有效受众：https://love.public.cat`

我使用的是 Keycloak SAML 客户端。插件是否有变更，需要在插件中额外设置？顺便一提，该插件使用环境变量，这使得它在多站点环境中难以使用。

我尝试在 Keycloak 中添加受众字段，但这没有带来任何变化。有什么建议吗？

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2020年五月16日 01:21 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589/2 "2020-05-16T01:21:15Z")

</div>

这里有什么想法吗，@vinothkannans？

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2020年五月18日 04:29 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589/3 "2020-05-18T04:29:58Z")

</div>

您是否在“全局设置”或环境变量中设置了 `saml_base_url`？在 [`/auth/saml/metadata`](https://love.public.cat/auth/saml/metadata) 中，该值的错误为 `www.example.com`，而正确值应为 `love.public.cat`。默认情况下，您无需为该设置指定任何值。

---

<div class="post-metadata">

### Author: ![hellekin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hellekin/32/51636_2.png) [@hellekin](https://meta.discourse.org/u/hellekin)
#### Post date: [2020年五月19日 09:58 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589/4 "2020-05-19T09:58:14Z")

</div>

不，我并没有在任何地方指定这一点。我测试了在 Keycloak 端移除等效设置，结果导致认证失败。我也尝试过移除 SSO，同样失败了。我需要进一步调查，因为在不同的多站点安装中，即使 Discourse 和 Keycloak 的 SAML 设置相同，表现也不一致。这是否可能与 SSO 存在不良交互？例如，某种认证模式在某个时刻接管了另一种？

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [2020年五月19日 15:48 UTC](https://meta.discourse.org/t/saml-error-after-upgrade/151589/5 "2020-05-19T15:48:38Z")

</div>

我们从未在多个站点中测试过“discourse-saml”插件。该插件可能不兼容此场景。我不建议同时为多个站点启用 SAML 插件。请在 `app.yml` 文件中设置所有环境变量。
