您好!
我们之前通过 AzureAD 成功使用了 SAML 插件,但昨天我们升级到最新的 commit 后,用户尝试通过 SAML 进行身份验证时开始出现以下错误:
Sign in
Sorry, but we’re having trouble signing you in.
AADSTS7500525: There was an XML error in the SAML message at line 1, position 1. Verify that the XML content of the SAML messages conforms to the SAML protocol specifications.
此链接 Azure AD SAML2 request rejected: AADSTS7500525 - Microsoft Q&A 表明这可能是由 AzureAD 不支持的“压缩 SAML 身份验证请求”引起的。
12 月的 commit 中有许多关于 SAML 的更改(例如,通过站点设置进行配置),但我无法确定是否有任何与 SAML 请求相关的更改可能导致此问题。
SAML 配置(在更新之前运行正常):
## Saml plugin setting
DISCOURSE_SAML_TARGET_URL: https://login.microsoftonline.com/<<our app id>>/saml2
DISவதால்_SAML_CERT_FINGERPRINT: "<<our fingerprint>>"
DISCOURSE_SAML_REQUEST_METHOD: POST
#DISCOURSE_SAML_FULL_SCREEN_LOGIN: true
DISCOURSE_SAML_CERT: "-----BEGIN CERTIFICATE-----
<<Our cert payload>>
-----END CERTIFICATE-----"
DISCOURSE_SAML_SYNC_GROUPS: true
DISCOURSE_SAML_GROUPS_ATTRIBUTE: http://schemas.microsoft.com/ws/2008/06/identity/claims/role
DISCOURSE_SAML_GROUPS_FULLSYNC: true
如何启用身份验证调试以获取有关此问题的更多信息?
1 个赞
david
(David Taylor)
2021 年12 月 14 日 21:17
2
很抱歉听到您遇到了问题!您说得对,我最近几周一直在对 SAML 插件进行大量重构,所以这可能与之有关。
这发生在什么时候?用户发起登录时?还是当他们返回 Discourse 时?
您能否在此处或通过私信分享您的网站 URL?
1 个赞
每当用户需要登录时(会话过期或新用户尝试登录),就会发生这种情况。
在我更新到修订版 9334abe249 (之前是 959923d3cf)后,开始出现此问题。
抱歉,我们的论坛托管在我们私有的 AWS 账户中,因此您无法从我们的网络外部访问。
david
(David Taylor)
2021 年12 月 14 日 21:50
6
错误出现在哪里?Discourse 日志中?用户屏幕上?Azure 中?
可以分享一些截图吗?
1 个赞
我也尝试在 discourse 的日志中查找一些信息,但由于错误发生在 Azure 端,因此在那里没有找到任何错误消息。
在 production.log 中,登录过程在此处停止(可能正在等待 Azure 的响应):
> Processing by StaticController#show as HTML
Parameters: {"id"=>"login"}
Rendered static/login.html.erb (Duration: 17.5ms | Allocations: 1440)
Completed 200 OK in 19ms (Views: 18.3ms | ActiveRecord: 0.0ms | Allocations: 2104)
Started GET "/session/csrf" for <<IP>> at 2021-12-14 18:28:16 -0300
Processing by SessionController#csrf as JSON
Completed 200 OK in 1ms (Views: 0.1ms | ActiveRecord: 0.0ms | Allocations: 337)
Started POST "/auth/saml" for <<IP>> at 2021-12-14 18:28:16 -0300
(saml) Setup endpoint detected, running now.
(saml) Request phase initiated.
负责 Azure 的团队正在尝试获取他们收到的 XML,这样我们也许能看到一些“不同”的地方。他们发送给我后我会通知你。
1 个赞
错误发生在用户点击登录按钮后。
然后它会重定向到 Azure 登录页面并显示以下错误:
david
(David Taylor)
2021 年12 月 14 日 22:24
9
在没有访问站点的情况下,恐怕很难弄清楚这里发生了什么。
下一步将是尝试获取 Azure 收到的 XML,并弄清楚它有什么问题。您应该能够通过在浏览器的开发者工具中检查有效负载,然后使用类似此 的工具进行解码来做到这一点。
2 个赞
太棒了!
请求的返回是 http 状态码 400:
请求 URL:https://login.microsoftonline.com/APP_ID/saml2
请求方法:POST
状态码:400 Bad Request
远程地址:20.190.173.144:443
引用策略:strict-origin-when-cross-origin
膨胀后的 SAMLRequest 是(为保护隐私隐藏了一些 ID):
<samlp:AuthnRequest AssertionConsumerServiceURL='https://INTERNAL_URL/auth/saml/callback' Destination='https://login.microsoftonline.com/APP_ID/saml2' ID='_11111111-1111-1111-1111-111111111111' IssueInstant='2021-12-14T22:33:29Z' Version='2.0' xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'><saml:Issuer>https://INTERNAL_URL</saml:Issuer></samlp:AuthnRequest>
我注意到将我的请求与 Single sign-on SAML protocol - Microsoft identity platform | Microsoft Learn 上的示例进行比较时,我的 AuthnRequest 中缺少以下参数:
xmlns="urn:oasis:names:tc:SAML:2.0:metadata"
david
(David Taylor)
2021 年12 月 15 日 00:31
12
4 个赞