samedi 2 mai 2020

Simple test script for initialized SAML authentication with PySAML2

I'm trying to create a simple script, starting from PySAML2 examples to make SAML post request to a service provider.

The problem is that the SAML doesn't contains any AttributeStatement at all:

...
<ns1:Assertion ID="id-SuNnG9nMIL7IOyx6Q" IssueInstant="2020-05-02T13:58:14Z" Version="2.0">
     ... No attribute statement ...
</ns1:Assertion>
...

Currently, I configured the script as follow:

USERS = {
  "babs": {
    "FirstName": "Babs",
    "LastName": "Ozzie",
    "Email": "affiliate",
  },
}
user = "babs"
sp_entity_id = "https://www.example.com/saml2_auth/acs/" 
destination = "https://www.example.com/saml2_auth/acs/"
binding_out = BINDING_HTTP_POST

IDP = server.Server("idp_conf", cache=Cache())

identity = USERS[user].copy()
_resp = IDP.create_authn_response(
    identity=identity,
    in_response_to=None,
    destination=destination,
    sp_entity_id=sp_entity_id,
    userid=user
)
dom = xml.dom.minidom.parseString("%s" % _resp)
print(dom.toprettyxml())

This is my idp_conf file:

CONFIG = {
    "entityid": "%s/idp.xml" % BASE,
    "description": "My IDP",
    "valid_for": 168,
    "service": {
        "idp": {
            "name": "Rolands IdP",
            "policy": {
                "default": {
                    "lifetime": {"minutes": 15},
                    "attribute_restrictions": None, # means all I have
                    "name_form": NAME_FORMAT_URI,
                    "entity_categories": ["swamid", "edugain"]
                },
            },
            "subject_data": "./idp.subject",
            "name_id_format": [NAMEID_FORMAT_TRANSIENT,
                               NAMEID_FORMAT_PERSISTENT]
        },
    },
    "debug": 1,
    "key_file": full_path("pki/mykey.pem"),
    "cert_file": full_path("pki/mycert.pem"),
    "metadata": {
        "local": [full_path("sp.xml")],
    },
}

Does anybody know which configuration I'm missing to display all the attribute statement from the user identity information? e.g. :

    <saml:AttributeStatement>
        <saml:Attribute Name="FirstName" NameFormat="...">
            <saml:AttributeValue xsi:type="xs:string">Babs</saml:AttributeValue>
        </saml:Attribute>
        ...
    </saml:AttributeStatement>

Aucun commentaire:

Enregistrer un commentaire