pip_services3_components.auth.CredentialParams module
pip_services3_components.auth.CredentialParams
Credential parameters implementation
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_components.auth.CredentialParams.
CredentialParams
(values: Any = None) Bases:
pip_services3_commons.config.ConfigParams.ConfigParams
Contains credentials to authenticate against external services.
They are used together with connection parameters, but usually stored in a separate store, protected from unauthorized access.
- ### Configuration parameters ###
store_key: key to retrieve parameters from credential store
username: user name
user: alternative to username
password: user password
pass: alternative to password
access_id: application access id
client_id: alternative to access_id
access_key: application secret key
client_key: alternative to access_key
secret_key: alternative to access_key
In addition to standard parameters CredentialParams may contain any number of custom parameters
Example:
credential = CredentialParams.from_tuples ("user", "jdoe", "pass", "pass123", "pin", "321") username = credential.get_username() # Result: "jdoe" password = credential.get_password() # Result: "pass123" pin = credential.get_as_nullable_string("pin") # Result: 321
-
static
from_config
(config: pip_services3_commons.config.ConfigParams.ConfigParams) → pip_services3_components.auth.CredentialParams.CredentialParams Retrieves a single CredentialParams from configuration parameters from “credential” section. If “credentials” section is present instead, then is returns only the first credential element.
- Parameters
config – ConfigParams, containing a section named “credential(s)”.
- Returns
the generated CredentialParams object.
-
static
from_string
(line: str) → pip_services3_components.auth.CredentialParams.CredentialParams Creates a new CredentialParams object filled with key-value pairs serialized as a string.
- Parameters
line – a string with serialized key-value pairs as “key1=value1;key2=value2;…” Example: “Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z”
- Returns
a new CredentialParams object.
-
static
from_tuples
(*tuples: Any) → pip_services3_components.auth.CredentialParams.CredentialParams Creates a new CredentialParams object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, … pairs.
- Parameters
tuples – the tuples to fill a new CredentialParams object.
- Returns
a new CredentialParams object.
-
get_access_id
() → str Gets the application access id. The value can be stored in parameters “access_id” pr “client_id”
- Returns
the application access id.
-
get_access_key
() → str Gets the application secret key. The value can be stored in parameters “access_key”, “client_key” or “secret_key”.
- Returns
the application secret key.
-
get_password
() → str Get the user password. The value can be stored in parameters “password” or “pass”.
- Returns
the user password.
-
get_store_key
() → str Gets the key to retrieve these credentials from
ICredentialStore
. If this key is null, than all parameters are already present.- Returns
the store key to retrieve credentials.
-
get_username
() → str Gets the user name. The value can be stored in parameters “username” or “user”.
- Returns
the user name.
-
static
many_from_config
(config: pip_services3_commons.config.ConfigParams.ConfigParams) → List[pip_services3_components.auth.CredentialParams.CredentialParams] Retrieves all CredentialParams from configuration parameters from “credentials” section. If “credential” section is present instead, than it returns a list with only one CredentialParams.
- Parameters
config – a configuration parameters to retrieve credentials
- Returns
a list of retrieved CredentialParams
-
set_access_id
(value: str) Sets the application access id.
- Parameters
value – a new application access id.
-
set_access_key
(value: str) Sets the application secret key.
- Parameters
value – a new application secret key.
-
set_store_key
(value: str) Sets the key to retrieve these parameters from
ICredentialStore
.- Parameters
value – a new key to retrieve credentials.
-
use_credential_store
() → bool Checks if these credential parameters shall be retrieved from
ICredentialStore
. The credential parameters are redirected toICredentialStore
when store_key parameter is set.- Returns
true if credentials shall be retrieved from
ICredentialStore