pip_services3_components.auth.CredentialResolver module

pip_services3_components.auth.CredentialResolver

Credential resolver 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.CredentialResolver.CredentialResolver(config: pip_services3_commons.config.ConfigParams.ConfigParams = None, references: pip_services3_commons.refer.IReferences.IReferences = None)

Bases: pip_services3_commons.config.IConfigurable.IConfigurable, pip_services3_commons.refer.IReferenceable.IReferenceable

Helper class to retrieve component credentials.

If credentials are configured to be retrieved from ICredentialStore, it automatically locates ICredentialStore in component references and retrieve credentials from there using store_key parameter.

### Configuration parameters ### credential:

  • store_key: (optional) a key to retrieve the credentials from ICredentialStore

  • … other credential parameters

credentials: alternative to credential
  • [credential params 1]: first credential parameters

  • … credential parameters for key 1

  • [credential params N]: Nth credential parameters

  • … credential parameters for key N

### References ###
  • *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials

Example:

config = ConfigParams.from_tuples("credential.user", "jdoe",
                                  "credential.pass",  "pass123")

credentialResolver = CredentialResolver()
credentialResolver.configure(config)
credentialResolver.set_references(references)
credentialResolver.lookup("123")
add(connection: pip_services3_components.auth.CredentialParams.CredentialParams)

Adds a new credential to component credentials

Parameters

connection – new credential parameters to be added

configure(config: pip_services3_commons.config.ConfigParams.ConfigParams)

Configures component by passing configuration parameters.

Parameters

config – configuration parameters to be set.

get_all() → List[pip_services3_components.auth.CredentialParams.CredentialParams]

Gets all credentials configured in component configuration.

Redirect to CredentialStores is not done at this point. If you need fully fleshed credential use lookup() method instead.

Returns

a list with credential parameters

lookup(correlation_id: Optional[str]) → Optional[pip_services3_components.auth.CredentialParams.CredentialParams]

Looks up component credential parameters. If credentials are configured to be retrieved from Credential store it finds a ICredentialStore and lookups credentials there.

Parameters

correlation_id – (optional) transaction id to trace execution through call chain.

Returns

resolved credential parameters or None if nothing was found.

set_references(references: pip_services3_commons.refer.IReferences.IReferences)

Sets references to dependent components.

Parameters

references – references to locate the component dependencies.