Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrating python-saml with an ADFS IDP #180

Closed
kowsari opened this issue Feb 3, 2017 · 10 comments
Closed

Integrating python-saml with an ADFS IDP #180

kowsari opened this issue Feb 3, 2017 · 10 comments

Comments

@kowsari
Copy link

kowsari commented Feb 3, 2017

Hi
I am recent user of python-saml and trying to get it integrated with an ADFS IDP and having a difficult time. Everything seems setup correctly on both sides with the URLS and certificates.

Even when all the signing options (authnRequestsSigned, wantMessagesSigned and wantAssertionsSigned) are set to false, I am getting a response from the IDP that the response is either:

The sign in request is not compliant to the WS-Federation language for web browser clients or the SAML 2.0 protocol WebSSO profile.

or

The verification of the SAML message signature failed.
Message issuer: https://dev.site.com/api/saml/metadata/
Exception details:
MSIS1016: Relying party trust 'https://dev.site.com/api/saml/metadata/' indicates that authentication requests sent by this relying party will be signed but no signature present.

My advanced_settings are
{
"security": {
"nameIdEncrypted": false,
"authnRequestsSigned": false,
"logoutRequestSigned": false,
"logoutResponseSigned": false,
"signMetadata": false,
"wantMessagesSigned": false,
"wantAssertionsSigned": false,
"wantNameId" : true,
"wantNameIdEncrypted": false,
"wantAssertionsEncrypted": false,
"signatureAlgorithm": "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
},
"contactPerson": {
"technical": {
"givenName": "Site Admin",
"emailAddress": "info@site.com"
},
"support": {
"givenName": "Site Support",
"emailAddress": "support@site.com"
}
},
"organization": {
"en-US": {
"name": "Site",
"displayname": "Site",
"url": "https://site.com"
}
}
}

I did try the lowercase urlencoding option which didnt make a difference. Anybody have experience with integrating python-saml with with ADFS?

Thanks!

@pitbulk
Copy link
Contributor

pitbulk commented Feb 6, 2017

If you read the error message of ADFS:

MSIS1016: Relying party trust '-----entityId-------'
indicates that authentication requests sent by this relying party will be signed
but no signature present.

so the AuthNRequest sent by python-saml is not signed... if you review your settings:

"authnRequestsSigned": false,

you will need to turn it:

"authnRequestsSigned": true,

and also provide x509 certificate and private key on the 'sp' settings section

If you want to create self-signed certs, you can do it at the https://www.samltool.com/self_signed_certs.php service, or using the command:

openssl req -new -x509 -days 3652 -nodes -out sp.crt -keyout saml.key

Remember to register SP's x509 certificate on the ADFS in order to let it validate the Signature of the AuthNRequest.

In addition review what NameIDFormat and what requestedAuthnContext values ADFS expects, and be sure you configure them properly on python-saml (review the settings documentation)

@kowsari
Copy link
Author

kowsari commented Feb 6, 2017

Hi,
Thank you for your quick reply. I have tried authnRequestsSigned set to both true and false, as well as tried other signed options on/off. I have also tried changing the nameid format, but all of these return the same error.

Also I have configured the certificates to use valid certs and not self signed. Also I put the sp certs in the sp.crt and sp.key files locally in the certs directory.

Do you have any other suggestions that I can try?

Thanks!

@pitbulk
Copy link
Contributor

pitbulk commented Feb 6, 2017

Have you tried the signature algorithm?

@kowsari
Copy link
Author

kowsari commented Feb 6, 2017

I tried sha-256
signatureAlgorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"

and that returns a
<samlp :StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
but the error that I get back on my server is
Invalid SAML Response. Not match the saml-schema-protocol-2.0.xsd

@pitbulk
Copy link
Contributor

pitbulk commented Feb 6, 2017

Then this was the issue, a SAMLResponse with Status = Success is ok.

Now let's try to figure out why the SAMLResponse is invalid...can you validate the SAMLResponse XML here:
https://www.samltool.com/validate_xml.php

@kowsari
Copy link
Author

kowsari commented Feb 6, 2017

Line: 18 | Column: 0 --> Element '{http://www.w3.org/2000/09/xmldsig#}X509SerialNumber': '137159247534293833333515219826463830998' is not a valid value of the atomic type 'xs:integer'.

@kowsari
Copy link
Author

kowsari commented Feb 6, 2017

This is the whole response
<samlp:Response Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified" Destination="https://dev.site.com/api/saml/?acs" ID="_212f8130-4f8e-4b64-a7fe-ec187750dfe0" InResponseTo="ONELOGIN_a61130917f6c1ed6c4c22e8af0548575cd59c209" IssueInstant="2017-02-06T20:19:14.684Z" Version="2.0" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"> <Issuer xmlns="urn:oasis:names:tc:SAML:2.0:assertion">http://edc-adfs-lb.chw.edu/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=RapidSSL SHA256 CA, O=GeoTrust Inc., C=US</ds:X509IssuerName> <ds:X509SerialNumber>137159247534293833333515219826463830998</ds:X509SerialNumber> </ds:X509IssuerSerial> </ds:X509Data> </KeyInfo> <e:CipherData> <e:CipherValue>UO2lgtfl/UdhhM23vWrXavml+B5DJLtEf9ZAtpt/O7fCRXlgSnQ2VpHht+Mz+MOA3y0o6wi/1+h0R1+epux11FMtbkpdLr95DniUx1q13555Mxfs+fLWdOdQc3r/tuXuB0W/+LWIcMjHPs+ftkuui8dA7cHVGafxBK4K/hUgMO0Jn+zpurzKEUQ3dSQMZONaUBdeg0IClXzl9JUAcaRhDFczRzGchklYI7plR2wQVzib+Oc5HSqFJSgGke2S6Eqer+gi+1NJ7VZkX16rM/Hqz7tm4T2VT4S/ONYHHfdSh1dECVozmgVV1c9JgFHyYVur0iJlenVEa5QudpAhVphAcw==</e:CipherValue> </e:CipherData> </e:EncryptedKey> </KeyInfo> <xenc:CipherData> <xenc:CipherValue>KA046S+L95t2fpZUopilcF7C5By89kQhAnTzxyB7qh5xbEJoTEC01o/6a9keU5hfJu71MTein3UG2dIaSpjCDDenwBpczHaIn7rgZR30IcecTUp67Pe1NEG7uuZGmwwy1eKfzWuuY8Pei5azWIfnwZxFs9pMl2TZeKuldKw2stAbpvbVSwMuJHdgGy1W9z1JKxGVfniw1oeZu8YnY/4dZanVDg/6nRp2VAsFg6st9GvwtK0qO8Hi5sF7DREHzb0nnZd0KQq699WbfzSjAtEKkk5zPGF5APYYsYaxrpuD6d9f0NpfRuu14WNw3ePzExifj+R4r0TljQltYNYWqD/qTfQAmaosS02Ua9iNXDaarvImlZ1OSlkJhbzbyD+eTu2FumM1OyBGKVnwMb15hz1LpSr06Iym3DCZ0ZW3VspTC16Uhs7E+2mLmIYXFf5+XTrvT7amamtcVb4ta0rJqV3fc+iXo3bgWvnIvu3EjOEgI148N1JVvfkK7XFtcqR+59HjbPfqPRo666ezbis6cClhPgHIrEiGA82DUY1F2wfJi4H9Sx3AjOp2Qrjd6/QeA5E/cLJnHtIB2b906AwMv35LNRUMg2gjC46E0zNKV9dfsHx4XouR3MLqBrhe+of+GLzdrRftPcaAit2Yw6X5cPQAsRBmWI8UxUPwvUudRzbPYDr2WQJz+XPJsgdsQKWt3hCSOum03FEyMAzJOqCaZ7SX2mc1Y5gHFF1d6j3fB+vAO/uyzfeUWcC+9BTFUD9nzcJETgVJKRzRUF1KgSctelXN2P7aHdG+1iSoytMr5ZkLZ1gLOIQXb4iuvCjj396/YWcFdbuyj/FEbtYm0IB1G6SYOhjvKfvf4PkUKtan+tpNvJjiw1mTZq7wUiHagWeyNeaZczgpXCx6xbx65R5boDkPiQIjr/5l5a40ROcTxR14/As7+t0ZhCJWwubt/Nhm5zj+0hO5mdorq9CYLzLykW1fMDY5lP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xWV6we+CabD/1j3NLl7A8m4lL19l7BWS6YukfDOSxxH5sWccDrbojw7zNNe9JOQyiRDzv5UTXdGJy8q1G10dRjBAz6+OfOs86ilU0T9NIFQ97dPRLdE8JO1cNbvzxN6rK7F2p7NF0WO7ic1tscVriLqHu3yGu1ssKQqEJQanXvaradxt81mbnz0euG/8/rae9BVnUn5EvIcWZE5Ya4Ggt3J5FqvMlBBBq66qN9pdoYMZcfuVZacSghieOaSXk9PZReC+eBfYTg700m9bUXL4Pme2k9Ps7yesMQrcXGh63NgiNXhONgql4paPs08L7n05SjFRV1HkW4DmVH58Y+hlsXxZ1lTj9i72SFkucLWnDxOnTyvjjgmN/a2aRjIo25zlf0fiycng5Kyb8WaynGr62wBsFiVjSl1ZFlsRewy1KYkVYTFb8f83i1tepBYPmuHy8LHS4MGHz8CBTLheoOmVlLz0somsh4U/Gqg5GnuF+W72E1PMYmHoeRprQ8eFFsABG9YN4SzXeKf9pBCDn+b7JkCWcJ5kjUTJXBe3RIJxzGN4A9Y1ue9QAoNNDGvkuZCEInH4Z/7pJsvBQG3AJlRfiM21pEyR8VTxUXCaBAqgFUcNuPpvAT5Kx/ILq7pS2c/8Mrw5+f+ti07bazNJbQis7EpRt0BmcEYKZYeBi7ijfvlMfVHqaOkUKrPa5w/QWfvm2UzhUG9uuV9n4UuBkz9nzl0AbRClhuB+f75GpI67+ynnNyuBHOMmSR+/TSywqVl/QZuVmLwz8tidtAF7aNu/DgA9YaYqajyKBZMrV0Gp5YWIPvHncvN906dvLZKCTQVDiInXAXHaUM7O3XyhLAlzQWUDpzVjc4aRmcWuJjfU7oaPZUfklpmYal8lgEBMfypIZaSI+HZpfJlQYaL95qkVmc0tlbFaCCGsoEkPMYAsxUtuAFWctFY3Qe66rJMWAY7JomJxEXaxC76FNG7NeOwh4/l0pv2w2xvKXzo=</xenc:CipherValue> </xenc:CipherData> </xenc:EncryptedData> </EncryptedAssertion> </samlp:Response>

@pitbulk
Copy link
Contributor

pitbulk commented Feb 6, 2017

I think I will neee to update the xsd file.

Here is a related issue:
benoist/xmldsig#31

Is related with the private key/public cert used at ADFS.

@kowsari
Copy link
Author

kowsari commented Feb 6, 2017

It works...I had to change apply the same change to the xsd manually and it goes further. It still had issues with Issuer...and I had to turn off strict in python-saml.

Can you apply the same change to python-saml as you did for the ruby-saml project at your earliest convenience?

Thanks!

@pitbulk
Copy link
Contributor

pitbulk commented Mar 6, 2017

Done 616f9fd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants