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


Alias for field number 0


Alias for field number 2


Alias for field number 4


Alias for field number 3


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.

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.