Secure storage for Authentication methods.
pytan3.auth_store.
DEFAULT_NAME
= 'credentials'¶str
– Default pytan3.auth_methods.AuthMethod
name to load in
AuthStore
.
pytan3.auth_store.
STORE_FILE
= '{http_client.parsed_url.hostname}.store'¶str
– Store filename template filename to use in AuthStore
.
Will use OS Environment variable “PYTAN_STORE_FILE” if set.
pytan3.auth_store.
AuthStore
(http_client, method='credentials', secret=None, data=None, src='init', lvl='info')[source]¶Bases: object
Secure storage for pytan3.auth_methods.AuthMethod
.
__init__
(http_client, method='credentials', secret=None, data=None, src='init', lvl='info')[source]¶Constructor.
Parameters: |
|
---|
http_client
¶Get the HTTP Client for this object.
Returns: | pytan3.http_client.HttpClient |
---|
get
(key, required=True)[source]¶Get key value from data.
Parameters: | |
---|---|
Raises: |
|
Returns: |
method
¶Get the method class for this store.
Returns: | pytan3.auth_methods.AuthMethod |
---|
create_method
(**kwargs)[source]¶Create an pytan3.auth_methods.AuthMethod
from this store.
Parameters: | **kwargs – Rest of kwargs passed to
pytan3.auth_methods.AuthMethod.from_store() . |
---|---|
Returns: | pytan3.auth_methods.AuthMethod |
to_stream
(stream=None)[source]¶Write this stores encrypted data to a file like object.
Parameters: | stream (io.IOBase , optional) – Object to write store to. If None, create and return a Defaults to: None. |
---|---|
Returns: | io.IOBase |
to_path
(path=None, path_sub='stores', path_file='{http_client.parsed_url.hostname}.store', overwrite=False)[source]¶Write this stores encrypted data to a path.
Parameters: |
|
---|---|
Raises: |
|
Returns: | Absolute full path where store file was written. |
Return type: |
from_stream
(http_client, stream, secret=None, src='stream', lvl='info')[source]¶Create store from encrypted data in a file like object.
Parameters: |
|
---|---|
Returns: |
from_string
(http_client, string, secret=None, lvl='info')[source]¶Create store from encrypted data in a string.
Parameters: |
|
---|---|
Returns: |
from_path
(http_client, path=None, path_sub='stores', path_file='{http_client.parsed_url.hostname}.store', secret=None, lvl='info')[source]¶Create store from encrypted data in a file.
Parameters: |
|
---|---|
Raises: | ( |
Returns: |
_decrypt
(data, http_client, secret=None)[source]¶Decrypt data using secret.
Parameters: |
|
---|---|
Returns: |
_encrypt
(data, http_client, secret=None)[source]¶Encrypt data using secret.
Parameters: |
|
---|---|
Returns: |
_build_key
(http_client, secret=None)[source]¶Build an encryption key by combining an SSL cert PEM and a secret.
Parameters: |
|
---|---|
Returns: |