使用 SAML 2.0 从 .net mvc 到另一个站点进行身份验证

Using SAML 2.0 to authenticate from .net mvc to another site

我以前从未使用过 SAML,有点困惑。我以为我可以只用 base64 编码 xml 和一个密钥就可以了,但显然没那么简单。

我必须将 SAMLRESPONSE 发送到 post 方法

<form method="post" action="%ACS" ...>
    <input type="hidden" name="SAMLResponse" value="%RESPONSE" />
    <input type="hidden" name="RelayState" value="%RELAYSTATE" />
     ...
</form>

操作是他们的 URL 和我在我这边生成的带有证书或 IDP MEta 数据和断言的 SAMLRESPONSE。我以为我可以编码我的 xml

<samlp:Response xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'ID='identifier_1'Version='2.0'IssueInstant='2004-12-05T09:22:05Z'Destination='https://sp.example.com/SAML2/SSO/POST'> <saml:Issuer>https://idp.example.org/SAML2</saml:Issuer> <samlp:Status> <samlp:StatusCode Value='urn:oasis:names:tc:SAML:2.0:status:Success'/> </samlp:Status> <saml:Assertion xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'ID='identifier_2'Version='2.0'IssueInstant='2004-12-05T09:22:05Z'> <saml:Issuer>https://idp.example.org/SAML2</saml:Issuer> <ds:Signature xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>...</ds:Signature> <saml:Subject> <saml:NameID Format='urn:oasis:names:tc:SAML:2.0:nameidformat:uid'> " + employeeID + " </saml:NameID> <saml:SubjectConfirmation Method='urn:oasis:names:tc:SAML:2.0:cm:bearer'> <saml:SubjectConfirmationData Recipient='https://sp.example.com/SAML2/SSO/POST'NotOnOrAfter='2004-12-05T09:27:05Z'/> </saml:SubjectConfirmation> </saml:Subject> <saml:Conditions NotBefore='2004-12-05T09:17:05Z'NotOnOrAfter='2004-12-05T09:27:05Z'> <saml:AudienceRestriction> <saml:Audience>https://sp.example.com/SAML2</saml:Audience> </saml:AudienceRestriction> </saml:Conditions> <saml:AuthnStatement AuthnInstant='2004-12-05T09:22:00Z'SessionIndex='identifier_2'> <saml:AuthnContext> <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:u nspecified</saml:AuthnContextClassRef> </saml:AuthnContext> </saml:AuthnStatement> </saml:Assertion> </samlp:Response>

提供商建议我使用 ADFS 3.0,但我想避免更改服务器上的任何内容。我可以使用不同的软件包来帮助这一切吗?

不要尝试自己动手。使用客户端 SAML 堆栈,例如SAML : SAML connectivity / toolkit.

此堆栈将 SAML 与 ADFS 等 IDP 通信。您需要使用客户端堆栈的 SAML 参数配置 ADFS。