From 38ab4a2b5d74e0e47d833c8dcaf6b2604ae9e468 Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Tue, 31 Oct 2017 11:26:24 -0400 Subject: flexible Basic versus non-basic ClientAuth to PDP PDP client (PolicyEngine.py) now can handle two formats of ClientAuth to match what we have in config * Basic * Change-Id: I4010d430a6675e3f259c1fc53b0b3373bd225352 Issue-Id: DCAEGEN2-128 Signed-off-by: Alex Shatov --- policyhandler/config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'policyhandler/config.py') diff --git a/policyhandler/config.py b/policyhandler/config.py index 5c7e962..7033096 100644 --- a/policyhandler/config.py +++ b/policyhandler/config.py @@ -143,7 +143,9 @@ class PolicyEngineConfig(object): config = Config.config[Config.FIELD_POLICY_ENGINE] headers = config["headers"] remove_basic = re.compile(r"(^Basic )") - client_parts = base64.b64decode(remove_basic.sub("", headers["ClientAuth"])).split(":") + client_auth = headers["ClientAuth"] + basic_client_auth = bool(remove_basic.match(client_auth)) + client_parts = base64.b64decode(remove_basic.sub("", client_auth)).split(":") auth_parts = base64.b64decode(remove_basic.sub("", headers["Authorization"])).split(":") props = PolicyEngineConfig.PYPDP_URL.format(config["url"], config["path_pdp"], @@ -154,7 +156,9 @@ class PolicyEngineConfig(object): with open(file_path, 'w') as prp_file: prp_file.write(props) - PolicyEngineConfig._logger.info("created %s", file_path) + PolicyEngineConfig._logger.info("created %s basic_client_auth %s", + file_path, basic_client_auth) + return basic_client_auth except IOError: PolicyEngineConfig._logger.error("failed to save to %s", file_path) except KeyError: -- cgit 1.2.3-korg