Skip to content

Commit 7352484

Browse files
committed
Fix formatting
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 74a0cd6 commit 7352484

File tree

1 file changed

+46
-27
lines changed

1 file changed

+46
-27
lines changed

src/saml2/client.py

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,13 @@ def do_logout(self, name_id, entity_ids, reason, expire, sign=None,
229229
for entity_id in entity_ids:
230230
logger.debug("Logout from '%s'", entity_id)
231231
# for all where I can use the SOAP binding, do those first
232-
for binding in [BINDING_SOAP, BINDING_HTTP_POST,
233-
BINDING_HTTP_REDIRECT]:
232+
for binding in [BINDING_SOAP, BINDING_HTTP_POST, BINDING_HTTP_REDIRECT]:
234233
if expected_binding and binding != expected_binding:
235234
continue
236235
try:
237-
srvs = self.metadata.single_logout_service(entity_id,
238-
binding,
239-
"idpsso")
236+
srvs = self.metadata.single_logout_service(
237+
entity_id, binding, "idpsso"
238+
)
240239
except:
241240
srvs = None
242241

@@ -247,19 +246,17 @@ def do_logout(self, name_id, entity_ids, reason, expire, sign=None,
247246
destination = next(locations(srvs), None)
248247
logger.info("destination to provider: %s", destination)
249248
try:
250-
session_info = self.users.get_info_from(name_id,
251-
entity_id,
252-
False)
249+
session_info = self.users.get_info_from(
250+
name_id, entity_id, False
251+
)
253252
session_indexes = [session_info['session_index']]
254253
except KeyError:
255254
session_indexes = None
256255
req_id, request = self.create_logout_request(
257256
destination, entity_id, name_id=name_id, reason=reason,
258257
expire=expire, session_indexes=session_indexes)
259258

260-
if sign is None:
261-
sign = self.logout_requests_signed
262-
259+
sign = sign if sign is not None else self.logout_requests_signed
263260
def_sig = DefaultSignature()
264261
sign_alg = def_sig.get_sign_alg() if sign_alg is None else sign_alg
265262
digest_alg = (
@@ -459,11 +456,21 @@ def do_authn_query(self, entity_id,
459456

460457
return None
461458

462-
def do_attribute_query(self, entityid, subject_id,
463-
attribute=None, sp_name_qualifier=None,
464-
name_qualifier=None, nameid_format=None,
465-
real_id=None, consent=None, extensions=None,
466-
sign=False, binding=BINDING_SOAP, nsprefix=None):
459+
def do_attribute_query(
460+
self,
461+
entityid,
462+
subject_id,
463+
attribute=None,
464+
sp_name_qualifier=None,
465+
name_qualifier=None,
466+
nameid_format=None,
467+
real_id=None,
468+
consent=None,
469+
extensions=None,
470+
sign=False,
471+
binding=BINDING_SOAP,
472+
nsprefix=None,
473+
):
467474
""" Does a attribute request to an attribute authority, this is
468475
by default done over SOAP.
469476
@@ -522,13 +529,19 @@ def do_attribute_query(self, entityid, subject_id,
522529
"subject_id": subject_id,
523530
"sign": sign}
524531
relay_state = self._relay_state(query.id)
525-
return self.apply_binding(binding, "%s" % query, destination,
526-
relay_state, sign=sign)
532+
return self.apply_binding(
533+
binding,
534+
str(query),
535+
destination,
536+
relay_state,
537+
sign=sign,
538+
)
527539
else:
528540
raise SAMLError("Unsupported binding")
529541

530-
def handle_logout_request(self, request, name_id, binding, sign=None,
531-
sign_alg=None, relay_state=""):
542+
def handle_logout_request(
543+
self, request, name_id, binding, sign=None, sign_alg=None, relay_state=""
544+
):
532545
"""
533546
Deal with a LogoutRequest
534547
@@ -571,16 +584,22 @@ def handle_logout_request(self, request, name_id, binding, sign=None,
571584
elif binding in [BINDING_HTTP_POST, BINDING_HTTP_REDIRECT]:
572585
response_bindings = [BINDING_HTTP_POST, BINDING_HTTP_REDIRECT]
573586
else:
574-
response_bindings = self.config.preferred_binding[
575-
"single_logout_service"]
587+
response_bindings = self.config.preferred_binding["single_logout_service"]
576588

577589
if sign is None:
578590
sign = self.logout_responses_signed
579591

580-
response = self.create_logout_response(_req.message, response_bindings,
581-
status, sign, sign_alg=sign_alg)
592+
response = self.create_logout_response(
593+
_req.message, response_bindings, status, sign, sign_alg=sign_alg
594+
)
582595
rinfo = self.response_args(_req.message, response_bindings)
583596

584-
return self.apply_binding(rinfo["binding"], response,
585-
rinfo["destination"], relay_state,
586-
response=True, sign=sign)
597+
return self.apply_binding(
598+
rinfo["binding"],
599+
response,
600+
rinfo["destination"],
601+
relay_state,
602+
response=True,
603+
sign=sign,
604+
sigalg=sign_alg,
605+
)

0 commit comments

Comments
 (0)