diff options
author | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-06-10 21:43:05 +0300 |
---|---|---|
committer | Ivan Kanakarakis <ivan.kanak@gmail.com> | 2020-06-11 00:47:51 +0300 |
commit | 8c9fc6a935a50da11cde89cbc55c8f1386bb3dbc (patch) | |
tree | 286888ebb256808c26456561aba087cefe67cc6c /src/saml2/client_base.py | |
parent | f42c3f8f8d03b7242ad2bea2f9b082f6d2e347ea (diff) | |
download | pysaml2-8c9fc6a935a50da11cde89cbc55c8f1386bb3dbc.tar.gz |
Refactor create_authn_request assertion_consumer_service_url
Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'src/saml2/client_base.py')
-rw-r--r-- | src/saml2/client_base.py | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/saml2/client_base.py b/src/saml2/client_base.py index 3b932d47..32346c85 100644 --- a/src/saml2/client_base.py +++ b/src/saml2/client_base.py @@ -313,30 +313,25 @@ class Base(Entity): args = {} - if self.config.getattr('hide_assertion_consumer_service', 'sp'): + # AssertionConsumerServiceURL + # AssertionConsumerServiceIndex + hide_assertion_consumer_service = self.config.getattr('hide_assertion_consumer_service', 'sp') + assertion_consumer_service_url = ( + kwargs.pop("assertion_consumer_service_urls", [None])[0] + or kwargs.pop("assertion_consumer_service_url", None) + ) + assertion_consumer_service_index = kwargs.pop("assertion_consumer_service_index", None) + service_url = (self.service_urls(service_url_binding or binding) or [None])[0] + if hide_assertion_consumer_service: args["assertion_consumer_service_url"] = None binding = None - else: - try: - args["assertion_consumer_service_url"] = kwargs[ - "assertion_consumer_service_urls"][0] - del kwargs["assertion_consumer_service_urls"] - except KeyError: - try: - args["assertion_consumer_service_url"] = kwargs[ - "assertion_consumer_service_url"] - del kwargs["assertion_consumer_service_url"] - except KeyError: - try: - args["assertion_consumer_service_index"] = str( - kwargs["assertion_consumer_service_index"]) - del kwargs["assertion_consumer_service_index"] - except KeyError: - if service_url_binding is None: - service_urls = self.service_urls(binding) - else: - service_urls = self.service_urls(service_url_binding) - args["assertion_consumer_service_url"] = service_urls[0] + elif assertion_consumer_service_url: + args["assertion_consumer_service_url"] = assertion_consumer_service_url + elif assertion_consumer_service_index: + args["assertion_consumer_service_index"] = assertion_consumer_service_index + elif service_url: + args["assertion_consumer_service_url"] = service_url + try: args["provider_name"] = kwargs["provider_name"] |