planet_auth_config_injection
The Planet Authentication Library Configration Injection Package: planet_auth_config_injection
This package provides interfaces and utilities for higher-level applications to inject configuration into the Planet Authentication Library.
The Planet Auth Library provides configuration injection to improve the
end-user experience of tools built on top of the Planet Auth Library.
This allows built-in default client configurations to be provided.
Namespacing may also be configured to avoid collisions in the Auth Library's
use of environment variables. Injected configration is primarily consumed
by initialization functionality in planet_auth_utils.PlanetAuthFactory
and the various planet_auth_utils provided click commands.
These concerns belong more to the final end-user application than to a library that sits between the Planet Auth library and the end-user application. Such libraries themselves may be used by a variety of applications in any number of deployment environments, making the decision of what configuration to inject a difficult one.
Library writers may provide configuration injection to their developers, but should be conscious of the fact that multiple libraries within an application may depend on Planet Auth libraries. Library writers are advised to provide configuration injection as an option for their users, and not silently force it into the loaded.
In order to inject configuration, the application writer must do two things:
- They must write a class that implements the planet_auth_config_injection.BuiltinConfigurationProviderInterface interface.
- They must set the environment variable
PL_AUTH_BUILTIN_CONFIG_PROVIDERto the fully qualified package, module, and class name of their implementation before any import of theplanet_authorplanet_auth_utilspackages.
planet_auth_config_injection.AUTH_BUILTIN_PROVIDER = 'PL_AUTH_BUILTIN_CONFIG_PROVIDER'
module-attribute
Environment variable to specify a python module and class that implement the BuiltinConfigurationProviderInterface abstract interface to provide the library and utility commands with some built-in configurations.
planet_auth_config_injection.BuiltinConfigurationProviderInterface
Bases: ABC
Interface to define built-in application configuration. This includes providing built-in auth client configuration profiles, pre-defined trust environments for server use, and namespacing for environment and global configuration variables.
Built-in profile names are expected to be all lowercase.
Built-in trust environments are expected to be all uppercase.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_client_authclient_config_dicts()
abstractmethod
Return a dictionary of built-in AuthClient configuration
dictionaries, keyed by a unique profile name.
The returned dictionary values should be suitable for
creating a functional configuration using
planet_auth.AuthClientConfig.config_from_dict
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_client_profile_aliases()
Return a dictionary profile aliases. Aliases allow for a single built-in configuration to be referred to by multiple names.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_default_profile()
abstractmethod
Return the built-in default fallback auth profile name of last resort.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_default_profile_by_client_type()
abstractmethod
Return a dictionary of client types to default profile names for each client type.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_trust_environment_names()
Return a list of the names of built-in trust environments.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.builtin_trust_environments()
Return a dictionary of the trust environment configurations. Each item in the lists should be valid AuthClient config dictionary.
This is primarily used for cases where planet_auth is used to validate tokens on the service side. This is the flip side of most of the other BuiltinConfigurationProviderInterface methods which are geared towards helping clients obtain tokens.
planet_auth_config_injection.BuiltinConfigurationProviderInterface.namespace()
Application namespace. This will be used as a prefix in various
contexts so that multiple applications may use the Planet auth
libraries in the same environment without collisions. Presently,
this namespace is used as a prefix for environment variables, and
as a prefix for config settings store to the user's ~/.planet.json
file.
planet_auth_config_injection.builtins_provider
planet_auth_config_injection.builtins_provider.AUTH_BUILTIN_PROVIDER = 'PL_AUTH_BUILTIN_CONFIG_PROVIDER'
module-attribute
Environment variable to specify a python module and class that implement the BuiltinConfigurationProviderInterface abstract interface to provide the library and utility commands with some built-in configurations.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface
Bases: ABC
Interface to define built-in application configuration. This includes providing built-in auth client configuration profiles, pre-defined trust environments for server use, and namespacing for environment and global configuration variables.
Built-in profile names are expected to be all lowercase.
Built-in trust environments are expected to be all uppercase.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_client_authclient_config_dicts()
abstractmethod
Return a dictionary of built-in AuthClient configuration
dictionaries, keyed by a unique profile name.
The returned dictionary values should be suitable for
creating a functional configuration using
planet_auth.AuthClientConfig.config_from_dict
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_client_profile_aliases()
Return a dictionary profile aliases. Aliases allow for a single built-in configuration to be referred to by multiple names.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_default_profile()
abstractmethod
Return the built-in default fallback auth profile name of last resort.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_default_profile_by_client_type()
abstractmethod
Return a dictionary of client types to default profile names for each client type.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_trust_environment_names()
Return a list of the names of built-in trust environments.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.builtin_trust_environments()
Return a dictionary of the trust environment configurations. Each item in the lists should be valid AuthClient config dictionary.
This is primarily used for cases where planet_auth is used to validate tokens on the service side. This is the flip side of most of the other BuiltinConfigurationProviderInterface methods which are geared towards helping clients obtain tokens.
planet_auth_config_injection.builtins_provider.BuiltinConfigurationProviderInterface.namespace()
Application namespace. This will be used as a prefix in various
contexts so that multiple applications may use the Planet auth
libraries in the same environment without collisions. Presently,
this namespace is used as a prefix for environment variables, and
as a prefix for config settings store to the user's ~/.planet.json
file.