0

我正在实施 saml SSO。在这个 IDP 是用 ruby​​ 编写的,SP 是用 java 编写的。对于 ruby​​,我们使用的是 saml_idp 和 ruby​​-saml gems。对于 java,我正在尝试使用 spring-security-saml-dsl。来自 SP 的 saml authrequest 格式如下

<?xml version="1.0" encoding="UTF-8"?>
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="https://localhost:9090/saml/SSO" Destination="https://localhost:3000/sso/saml" ForceAuthn="false" ID="a1g952c8gehic8503id5fbdi1cchhic" IsPassive="false" IssueInstant="2020-04-09T09:08:06.814Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Version="2.0"><saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">https://localhost:9090/saml/metadata</saml2:Issuer><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><ds:Reference URI="#a1g952c8gehic8503id5fbdi1cchhic"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><ds:DigestValue>59Sqiz0XoMFOwgquHILLLnmtzb0=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>sign</ds:SignatureValue><ds:KeyInfo><ds:X509Data><ds:X509Certificate>cert</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature>
</saml2p:AuthnRequest>

但这并没有被 IDP 接受。经过调查,我发现如果格式如下所示,IDP 允许

<samlp:AuthnRequest xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" AssertionConsumerServiceURL="http://localhost:8000/saml/acs" Destination="http://localhost:3050/saml/saml_assertion" ID="_06f89146-44ad-48e3-9110-cf068b7cd639" IssueInstant="2020-04-09T07:15:16Z" Version="2.0">
  <saml:Issuer>http://localhost:3050/saml/metadata</saml:Issuer>
  <samlp:NameIDPolicy AllowCreate="true" Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress"/>
</samlp:AuthnRequest>

我如何使 spring-security-saml-dsl(java SP) 以“samlp”格式而不是“saml2p”发送?或者我如何让 saml_idp(ruby IDP) 也接受“saml2p”格式?

4

1 回答 1

0

我的设置完全错误。因此问题。这些库(saml_idp 和 ruby​​-saml)接受 'samlp' 和 'saml2p' 前缀。我在我的 SP 中创建了带有 HTTP-POST 绑定的 saml AuthnRequest,并手动将其传递给 IDP 进行测试。在 IDP 中,SamlIdp::Controller.decode_request 用于解码此请求。这部分解码了请求。因此问题。

当我从 HTTP-POST 绑定更改为 HTTP-Redirect 绑定时,这开始工作了。似乎这个 SamlIdp::Controller.decode_request 期望 AuthnRequest 被压缩,这发生在 HTTP-Redirect 绑定中。现在我能够成功地集成我的 SP 和 IDP。

于 2020-04-11T12:01:42.457 回答