Я пытаюсь реализовать механизм аутентификации / авторизации, используя Spring Boot 2.1.6 + SAML 2.0 (1.0.10.RELEASE) + ADFS 2.0 в одном из наших проектов. Запросы от SP к IdP (ADFS 2.0) и ответы от IdP к SP go хорошо. Значение InResponseTo соответствует идентификатору AuthnRequest, отправленному в IdP. Однако по любой причине WebSSOProfileConsumer при обработке ответа IdP не находит сообщение в HttpSessionStore - org.springframework.security.saml.storage.HttpSessionStorage#retrieveMessage.
На самом деле карта пуста.
15:11:20.603 DEBUG [https-jsse-nio-8443-exec-8] o.s.s.s.s.HttpSessionStorage Storing message a2cj8718fe73aa014a9fadi5e8eagcj to session 1DDE042B05BC7239053734119975A884
15:11:21.948 INFO [https-jsse-nio-8443-exec-8] o.s.s.s.l.SAMLDefaultLogger AuthNRequest;SUCCESS;0:0:0:0:0:0:0:1;ENTITY_ID;http://ADFS_HOST_NAME/adfs/services/trust;;;
15:12:03.882 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.SAMLProcessingFilter Request is to process authentication
15:12:03.882 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.SAMLProcessingFilter Attempting SAML2 authentication using profile urn:oasis:names:tc:SAML:2.0:profiles:SSO:browser
15:12:04.026 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.p.SAMLProcessorImpl Retrieving message using binding urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST
15:12:04.055 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.u.SAMLUtil Found endpoint org.opensaml.saml2.metadata.impl.AssertionConsumerServiceImpl@5ef389cc for request URL https://SP_HOST_NAME:8443/saml/SSO based on location attribute in metadata
15:12:13.127 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.s.HttpSessionStorage Message a2cj8718fe73aa014a9fadi5e8eagcj not found in session 8E4443CA6E75F206154DA5D80F3E8C42
15:12:37.889 DEBUG [https-jsse-nio-8443-exec-10] o.s.s.s.SAMLAuthenticationProvider Error validating SAML message
org.opensaml.common.SAMLException: InResponseToField of the Response doesn't correspond to sent message a2cj8718fe73aa014a9fadi5e8eagcj
at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:175)
Я вижу, что идентификатор сеанса запроса отличается от ответа ID сеанса.
Ответ ADFS имеет этот формат
<samlp:Response Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
Destination="https://SP_HOST_NAME:8443/saml/SSO" ID="_9bb358cc-841d-432a-b2a6-87470a535d72"
InResponseTo="a59545jh68b8fa7d3a1cc615j4gd9" IssueInstant="2020-04-03T10:38:08.922Z" Version="2.0"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
<Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://ADFS_HOST_NAME/adfs/services/trust</Issuer>
<samlp:Status><samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/></samlp:Status>
<EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/></e:EncryptionMethod>
<KeyInfo>
<ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=XXX YYYY, OU=Users, O=ORGANISATION_NAME, L=LOCATION, S=Unknown, C=COUNTRY</ds:X509IssuerName>
<ds:X509SerialNumber>1160660393</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</KeyInfo>
<e:CipherData>
<e:CipherValue>A_VALUE</e:CipherValue>
</e:CipherData>
</e:EncryptedKey>
</KeyInfo>
<xenc:CipherData>
<xenc:CipherValue>A_SECOND_VALUE</xenc:CipherValue>
</xenc:CipherData>
</xenc:EncryptedData>
</EncryptedAssertion>
</samlp:Response>
Любая помощь высоко ценится. :) Спасибо.