一段时间以来,我一直在尝试联合 Office365 域,但一直没有成功。我已经到了收到请求并能够根据该请求生成响应的阶段,但不知道该响应是否正确。我收到此错误:
抱歉,我们无法为您登录
您无法使用组织帐户登录此网站。请确保您输入的网站地址正确。如果仍有问题,您可能需要联系您的管理员。
以下是我的 SAML 请求和响应(已删除敏感信息)
要求
<samlp:AuthnRequest
xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol'
xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'
ID='_1ae9c30e-8767-44e4-8221-ecd18d55e1c0'
IssueInstant='2015-03-09T20:46:12Z'
Version='2.0'
AssertionConsumerServiceIndex='0'>
<saml:Issuer>
urn:federation:MicrosoftOnline
</saml:Issuer>
<samlp:NameIDPolicy
Format='urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'/>
</samlp:AuthnRequest>
回复
<samlp:Response
Destination='https://login.microsoftonline.com/login.srf'
ID='AD5D2AFFA557338C737661EA4746DE1F5DEB0575C7'
InResponseTo='_1ae9c30e-8767-44e4-8221-ecd18d55e1c0'
IssueInstant='2015-03-09T20:46:12Z' 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>
http://self.clearlogin.com/
</saml:Issuer>
<samlp:Status>
<samlp:StatusCode Value='urn:oasis:names:tc:SAML:2.0:status:Success'/>
</samlp:Status>
<saml:Assertion ID='D1B7C4F18C08B5E2A0B4811121FF8FC18E5CE2C305'
IssueInstant='2015-03-09T20:46:12Z'
Version='2.0'
xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion'>
<saml:Issuer>
http://self.clearlogin.com/
</saml:Issuer>
<ds:Signature xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>
<ds:SignedInfo xmlns:ds='http://www.w3.org/2000/09/xmldsig#'>
<ds:CanonicalizationMethod Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/>
<ds:SignatureMethod Algorithm='http://www.w3.org/2001/04/xmldsig-more#rsa-sha1'/>
<ds:Reference URI='#D1B7C4F18C08B5E2A0B4811121FF8FC18E5CE2C305'>
<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/2001/04/xmlenc#sha1'/>
<ds:DigestValue>
[REDACTED]
</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
[REDACTED]
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
[REDACTED]
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
<saml:Subject>
<saml:NameID
Format='urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
NameQualifier='http://self.clearlogin.com'
SPNameQualifier='urn:federation:MicrosoftOnline'>
ABCDEG1234567890
</saml:NameID>
<saml:SubjectConfirmation
Method='urn:oasis:names:tc:SAML:2.0:cm:bearer'>
<saml:SubjectConfirmationData
InResponseTo='_1ae9c30e-8767-44e4-8221-ecd18d55e1c0'
NotOnOrAfter='2015-03-09T21:06:12Z'
Recipient='https://login.microsoftonline.com/login.srf'/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions
NotBefore='2015-03-09T20:46:12Z'
NotOnOrAfter='2015-03-09T21:06:12Z'>
<saml:AudienceRestriction>
<saml:Audience>
urn:federation:MicrosoftOnline
</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant='2015-03-09T20:46:12Z'>
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:Password
</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute Name='IDPEmail'>
<saml:AttributeValue xsi:type='xs:string'
xmlns:xs='http://www.w3.org/2001/XMLSchema'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
[REDACTED]
</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>
身份提供商
我们正在使用第三方 idP(我们自己)来创建 SAML 响应。我们不是使用 ADFS。
设置 MsolDomainAuthentication
Import-Module MSOnline
$idpSub = Read-Host 'Please enter the idP subdomain on clearlogin.com: '
$passiveLogin = "https://"+idpSub+".clearlogin-stage.com/apps/office365/login"
$logout = "https://"+$idpSub+".clearlogin-stage.com/apps/logout"
$issuer = "https://"+$idpSub+".clearlogin-stage.com/"
$certPath = C:\Users\MyUser\Desktop
$cert = New-Object
System.Security.Cryptography.X509Certificates.X509Certificate2($certPath)
$certData = [system.convert]::tobase64string($cert.rawdata)
$msdomain = Read-Host 'Please enter your Office365 domain.'
Set-MsolDomainAuthentication
-Authentication Federated
-DomainName $msdomain
-FederationBrandName $msdomain
-IssuerUri $issuer
-LogOffUri $logout
-PassiveLogOnUri $passiveLogin
-SigningCertificate $certData
-PreferredAuthenticationProtocol Samlp
编辑1:
添加了一些更多信息和我的 Set-MsolDomainAuthentication 命令。
答案1
问题似乎出在几个地方。证书的颁发者编码有误,摘要值也错误。