diff --git a/oscar_python/_utils.py b/oscar_python/_utils.py index 3bd7391..4d4767e 100644 --- a/oscar_python/_utils.py +++ b/oscar_python/_utils.py @@ -48,9 +48,11 @@ def get_headers(c): usr_pass_as_bytes = bytes(c.user+":"+c.password,"utf-8") usr_pass_base_64 = base64.b64encode(usr_pass_as_bytes).decode("utf-8") return {"Authorization": "Basic "+ usr_pass_base_64} - if c._AUTH_TYPE == "oidc": + if c._AUTH_TYPE == "oidc-agent": token = agent.get_access_token(c.shortname) return get_headers_with_token(token) + if c._AUTH_TYPE == "oidc": + return get_headers_with_token(c.oidc_token) """ Function to generate headers with token auth """ def get_headers_with_token(token): diff --git a/oscar_python/client.py b/oscar_python/client.py index f8b77d4..1f7941c 100644 --- a/oscar_python/client.py +++ b/oscar_python/client.py @@ -16,7 +16,8 @@ import json import yaml import liboidcagent as agent -import oscar_python._utils as utils +#import oscar_python._utils as utils +import _utils as utils from oscar_python.storage import Storage _INFO_PATH = "/system/info" @@ -38,6 +39,8 @@ def __init__(self, options) -> None: self.set_auth_type(options) if self._AUTH_TYPE == 'basicauth': self.basic_auth_client(options) + if self._AUTH_TYPE == 'oidc-agent': + self.oidc_agent_client(options) if self._AUTH_TYPE == 'oidc': self.oidc_client(options) @@ -48,21 +51,29 @@ def basic_auth_client(self, options): self.password = options['password'] self.ssl = bool(options['ssl']) - def oidc_client(self, options): + def oidc_agent_client(self, options): self.id = options['cluster_id'] self.endpoint = options['endpoint'] self.shortname = options['shortname'] self.ssl = bool(options['ssl']) + + def oidc_client(self, options): + self.id = options['cluster_id'] + self.endpoint = options['endpoint'] + self.oidc_token = options['oidc_token'] + self.ssl = bool(options['ssl']) def set_auth_type(self, options): if 'user' in options: self._AUTH_TYPE = "basicauth" elif 'shortname' in options: - self._AUTH_TYPE = "oidc" + self._AUTH_TYPE = "oidc-agent" try: agent.get_access_token(options['shortname']) except agent.OidcAgentError as e: print("ERROR oidc-agent: {}".format(e)) + elif 'oidc_token' in options: + self._AUTH_TYPE == "oidc" else: raise ValueError("Unrecognized authentication credentials in options") diff --git a/version.py b/version.py index fb82a6f..8dc71bf 100644 --- a/version.py +++ b/version.py @@ -14,4 +14,4 @@ """Stores the package version.""" -__version__ = '1.1.0-beta2' \ No newline at end of file +__version__ = '1.1.0-beta3' \ No newline at end of file