mx-moth / flask-saml2

Flask library for building SAML Service Providers and Identity Providers
MIT License
70 stars 61 forks source link

ADFS SAMLResponse #8

Open Bondosan opened 5 years ago

Bondosan commented 5 years ago

I'm trying to implement a SP using ADFS as my IDP and I successfully receive a SAML Response via request.form['SAMLResponse']. I can take this response and decode to a string with str(decode_saml_xml(request.form['SAMLResponse']).decode()), but I'm not sure what to do with it next. I'm trying to get to the Name ID via assertion data. What is the recommend way to complete this task? Are all necessary modules built in? The parser.py in sp seemed promising, but none of the functions work for me - I get list index out of range. I'm not sure if I'm going about it the wrong way, or passing the wrong data to the ResponseParser class. I thought the decoded XML string would be good, along with my SPs private key, but maybe that isn't the case. Any guidance you can provide would be fantastic.

FMJansen commented 4 years ago

(I know this is probably a bit late, but for future reference)

The SAMLResponse is already parsed as far as I know. On this line it’s passed to the auth_data.

You can access it through auth_data = sp.get_auth_data_in_session() with the nameid being in auth_data.nameid. Other attributes passed from the IdP are in auth_data.attributes.

Hope I correctly understood this question and that it helps other people in the future :)