allensdk.core.authentication module

class allensdk.core.authentication.CredentialProvider[source]

Bases: abc.ABC

METHOD = 'custom'
provide(self, credential)[source]
class allensdk.core.authentication.DbCredentials(dbname, user, host, port, password)

Bases: tuple

dbname

Alias for field number 0

host

Alias for field number 2

password

Alias for field number 4

port

Alias for field number 3

user

Alias for field number 1

class allensdk.core.authentication.EnvCredentialProvider(environ: Optional[Dict[str, Any]] = None)[source]

Bases: allensdk.core.authentication.CredentialProvider

Provides credentials from environment variables for variables listed in CREDENTIAL_KEYS.

METHOD = 'env'
provide(self, credential)[source]
allensdk.core.authentication.credential_injector(credential_map: Dict[str, Any], provider: Union[allensdk.core.authentication.CredentialProvider, NoneType] = None)[source]

Decorator used to inject credentials from another source if not explicitly provided in the function call. This function will only supply values for keyword arguments. All keys defined in credential_map must correspond to keyword arguments in the function signature.

Parameters:
credential_map: Dict[Str: Any]

Dictionary where the keys are the keyword of a credential kwarg passed to the decorated function, and the values are the name of the credential in the credential provider (see CREDENTIAL_KEYS).

Example of credential_map for PostgresQueryMixin connecting to LIMS database:

{

“dbname”: “LIMS_DBNAME”, “user”: “LIMS_USER”, “host”: “LIMS_HOST”, “password”: “LIMS_PASSWORD”, “port”: “LIMS_PORT”

}

provider: Optional[CredentialProvider]

Subclass of CredentialProvider to provide credentials to the wrapped function. If left unspecified, will default to EnvCredentialProvider, which provides credentials from environment variables.

allensdk.core.authentication.get_credential_provider()[source]
allensdk.core.authentication.set_credential_provider(provider)[source]