CredentialResolver

Helper class used to retrieve component credentials.

Implements: IConfigurable, IReferenceable

Description

The CredentialResolver class is used to retrieve component credentials.

Important points

  • If credentials are configured to be retrieved from ICredentialStore, it will automatically locate ICredentialStore in component references and retrieve the credentials from there using the 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

Constructors

Creates a new instance of credentials resolver.

CredentialResolver(config: ConfigParams = None, references: IReferences = None)

  • config: ConfigParams - (optional) component configuration parameters
  • references: IReferences - (optional) component references

Instance methods

add

Adds a new credential to component credentials

add(connection: CredentialParams)

configure

Configures component by passing configuration parameters.

configure(config: ConfigParams)

  • config: ConfigParams - configuration parameters to be set.

get_all

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.

get_all(): List[CredentialParams]

lookup

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

lookup(context: Optional[IContext]): Optional[CredentialParams]

  • context: IContext - (optional) a context to trace execution through a call chain.
  • returns: Optional[CredentialParams] - resolved credential parameters or None if nothing was found.

set_references

Sets references to dependent components.

set_references(references: IReferences)

  • references: IReferences - references to locate the component dependencies.

Examples

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

credentialResolver = CredentialResolver()
credentialResolver.configure(config)
credentialResolver.set_references(references)
credentialResolver.lookup("123")

See also