Skip to content

Commit

Permalink
Added more comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-sean-floyd committed Oct 6, 2022
1 parent a1ebc09 commit 9082a2a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ You can set up the connection by creating a new instance of `Domino`:
- *api_proxy:* (Optional) Location of the Domino API proxy as host:port.
If set, this proxy will be used to intercept any Domino API requests and insert an auth token.
This is the preferred method of authentication. Alternatively, the same behavior can be achieved
by setting the `DOMINO_API_PROXY` environment variable.
by setting the `DOMINO_API_PROXY` environment variable (this variable is set inside a Domino run
container in version 5.4.0 or later).

- *api_key:* (Optional) An API key to authenticate with. If not
provided, the library expects to find one in the
Expand Down
19 changes: 15 additions & 4 deletions domino/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,20 @@ def __init__(self, api_proxy):
self.api_proxy = api_proxy

def __call__(self, r):
"""
Override the default __call__ method for the AuthBase base class.
Note this override is no-op, the actual work happens in the initialize method.
More more info, see:
https://docs.python-requests.org/en/master/user/advanced/
"""
return r

def __initialize__(self, session):
"""
Override the default __initialize__ method for the _SessionInitializer base class.
"""

session.proxies.update({
'http': f'http://{self.api_proxy}',
})
Expand Down Expand Up @@ -68,13 +79,13 @@ def get_auth_by_type(api_key=None, auth_token=None, domino_token_file=None, api_
7. api_key_from_env
"""

if api_proxy is not None:
if api_proxy:
return ProxyAuth(api_proxy)
elif auth_token is not None:
elif auth_token:
return BearerAuth(auth_token=auth_token)
elif domino_token_file is not None:
elif domino_token_file:
return BearerAuth(domino_token_file=domino_token_file)
elif api_key is not None:
elif api_key:
return HTTPBasicAuth("", api_key)
else:
# In the case that no authentication type was passed when this method
Expand Down

0 comments on commit 9082a2a

Please sign in to comment.