Skip to content

Commit 2587196

Browse files
committed
Refactor create_authn_request nsprefix, client_crt and sign
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent 433a788 commit 2587196

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/saml2/client_base.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,6 @@ def create_authn_request(self, destination, vorg="", scoping=None,
307307
:return: either a tuple of request ID and <samlp:AuthnRequest> instance
308308
or a tuple of request ID and str when sign is set to True
309309
"""
310-
client_crt = None
311-
if "client_crt" in kwargs:
312-
client_crt = kwargs["client_crt"]
313-
314310
args = {}
315311

316312
# AssertionConsumerServiceURL
@@ -403,10 +399,7 @@ def create_authn_request(self, destination, vorg="", scoping=None,
403399
pass
404400
args["name_id_policy"] = name_id_policy
405401

406-
try:
407-
nsprefix = kwargs["nsprefix"]
408-
except KeyError:
409-
nsprefix = None
402+
nsprefix = kwargs.get("nsprefix")
410403

411404
conf_sp_type = self.config.getattr('sp_type', 'sp')
412405
conf_sp_type_in_md = self.config.getattr('sp_type_in_metadata', 'sp')
@@ -441,11 +434,11 @@ def create_authn_request(self, destination, vorg="", scoping=None,
441434
AuthnRequest(), extensions, **kwargs
442435
)
443436
args.update(_args)
444-
445437
args.pop("id", None)
446438

447-
if sign is None:
448-
sign = self.authn_requests_signed
439+
client_crt = kwargs.get("client_crt")
440+
nsprefix = kwargs.get("nsprefix")
441+
sign = self.authn_requests_signed if sign is None else sign
449442

450443
if (sign and self.sec.cert_handler.generate_cert()) or client_crt is not None:
451444
with self.lock:

0 commit comments

Comments
 (0)