diff options
author | Alex Shatov <alexs@att.com> | 2017-10-31 11:26:24 -0400 |
---|---|---|
committer | Alex Shatov <alexs@att.com> | 2017-10-31 11:26:24 -0400 |
commit | 38ab4a2b5d74e0e47d833c8dcaf6b2604ae9e468 (patch) | |
tree | 79673ab66a5eacb8e47724118894f7b88903de99 /policyhandler/config.py | |
parent | 81a1b05ebd918c3a8148382661f00f3183894f9a (diff) |
flexible Basic versus non-basic ClientAuth to PDPv1.1.01.0.0-ONAP1.0.0-Amsterdam
PDP client (PolicyEngine.py) now can handle
two formats of ClientAuth to match what we have in config
* Basic <auth>
* <auth>
Change-Id: I4010d430a6675e3f259c1fc53b0b3373bd225352
Issue-Id: DCAEGEN2-128
Signed-off-by: Alex Shatov <alexs@att.com>
Diffstat (limited to 'policyhandler/config.py')
-rw-r--r-- | policyhandler/config.py | 8 |
1 files changed, 6 insertions, 2 deletions
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: |