saml Integrating Ruby(IDP) and Java(SP)



我正在实现saml SSO。在本文中,IDP是用ruby编写的,SP是用java编写的。对于ruby,我们使用saml_idp&红宝石色的saml宝石。对于java,我尝试使用spring-security-saml-dsl。来自SP的saml身份验证请求采用以下格式

<?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(javaSP(以"samlp"格式而不是"saml2p"格式发送?或者我如何使saml_idp(ruby idp(也接受"saml2p"格式?

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

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

最新更新