2424
2525from saml2 .response import authn_response
2626
27+ from saml2 import saml
28+
2729logger = logging .getLogger (__name__ )
2830
2931
@@ -53,7 +55,7 @@ def ecp_auth_request(cls, entityid=None, relay_state="", sign=False):
5355 # ----------------------------------------
5456 # <paos:Request>
5557 # ----------------------------------------
56- my_url = cls .service_url (BINDING_PAOS )
58+ my_url = cls .service_urls (BINDING_PAOS )[ 0 ]
5759
5860 # must_understand and actor according to the standard
5961 #
@@ -63,6 +65,19 @@ def ecp_auth_request(cls, entityid=None, relay_state="", sign=False):
6365
6466 eelist .append (element_to_extension_element (paos_request ))
6567
68+ # ----------------------------------------
69+ # <samlp:AuthnRequest>
70+ # ----------------------------------------
71+
72+ logger .info ("entityid: %s, binding: %s" % (entityid , BINDING_SOAP ))
73+
74+ location = cls ._sso_location (entityid , binding = BINDING_SOAP )
75+ req_id , authn_req = cls .create_authn_request (
76+ location , binding = BINDING_PAOS , service_url_binding = BINDING_PAOS )
77+
78+ body = soapenv .Body ()
79+ body .extension_elements = [element_to_extension_element (authn_req )]
80+
6681 # ----------------------------------------
6782 # <ecp:Request>
6883 # ----------------------------------------
@@ -74,14 +89,16 @@ def ecp_auth_request(cls, entityid=None, relay_state="", sign=False):
7489# )
7590#
7691# idp_list = samlp.IDPList(idp_entry= [idp])
77- #
78- # ecp_request = ecp.Request(
79- # actor = ACTOR, must_understand = "1",
80- # provider_name = "Example Service Provider",
81- # issuer=saml.Issuer(text="https://sp.example.org/entity"),
82- # idp_list = idp_list)
83- #
84- # eelist.append(element_to_extension_element(ecp_request))
92+
93+ idp_list = None
94+ ecp_request = ecp .Request (
95+ actor = ACTOR ,
96+ must_understand = "1" ,
97+ provider_name = None ,
98+ issuer = saml .Issuer (text = authn_req .issuer .text ),
99+ idp_list = idp_list )
100+
101+ eelist .append (element_to_extension_element (ecp_request ))
85102
86103 # ----------------------------------------
87104 # <ecp:RelayState>
@@ -95,19 +112,6 @@ def ecp_auth_request(cls, entityid=None, relay_state="", sign=False):
95112 header = soapenv .Header ()
96113 header .extension_elements = eelist
97114
98- # ----------------------------------------
99- # <samlp:AuthnRequest>
100- # ----------------------------------------
101-
102- logger .info ("entityid: %s, binding: %s" % (entityid , BINDING_SOAP ))
103-
104- location = cls ._sso_location (entityid , binding = BINDING_SOAP )
105- req_id , authn_req = cls .create_authn_request (
106- location , binding = BINDING_PAOS , service_url_binding = BINDING_PAOS )
107-
108- body = soapenv .Body ()
109- body .extension_elements = [element_to_extension_element (authn_req )]
110-
111115 # ----------------------------------------
112116 # The SOAP envelope
113117 # ----------------------------------------
@@ -126,7 +130,7 @@ def handle_ecp_authn_response(cls, soap_message, outstanding=None):
126130 if item .c_tag == "RelayState" and item .c_namespace == ecp .NAMESPACE :
127131 _relay_state = item
128132
129- response = authn_response (cls .config , cls .service_url (), outstanding ,
133+ response = authn_response (cls .config , cls .service_urls (), outstanding ,
130134 allow_unsolicited = True )
131135
132136 response .loads ("%s" % rdict ["body" ], False , soap_message )
0 commit comments