antimatter.auth.config.auth_config#

Module Contents#

Classes#

AuthConfig

The AuthConfig is responsible for interacting with the config file and locally

Attributes#

antimatter.auth.config.auth_config.SUPPORTED_SCHEMA_VERSIONS = ['v1']#
antimatter.auth.config.auth_config.SUPPORTED_TOKEN_TYPES = ['google']#
class antimatter.auth.config.auth_config.AuthConfig#

The AuthConfig is responsible for interacting with the config file and locally storing profile and identity information.

schema: str#
profiles: List[antimatter.auth.config.profiles.Profile]#
active_profile: str | None#
global_identities: List[antimatter.auth.config.global_identity.GlobalIdentity]#
active_global_identity: str | None#
static from_dict(conf_dict: Dict[str, Any] | None) AuthConfig#

Load an AuthConfig from a json serializable dictionary in the expected config format.

Parameters:

conf_dict – The json serializable dictionary to parse into an AuthConfig

Returns:

The parsed AuthConfig

add_observers()#
to_dict() Dict[str, Any]#

Convert an AuthConfig into a dictionary.

Returns:

The dictionary containing AuthConfig values

static from_file(path: str = None) AuthConfig#

Load an AuthConfig from a config file.

Parameters:

path – Override path to the config file. If not provided, default path will be used

Returns:

The parsed AuthConfig

to_file(path: str = None) None#

Save the values in the AuthConfig into the config file. Note that this will create the file and parent directories if it does not exist, and will overwrite the file if it does exist.

Parameters:

path – Override path to the config file. If not provided, default path will be used

add_profile(domain_id: str, api_key: str = None, name: str | None = None, default_read_context: str | None = None, default_write_context: str | None = None, mark_active: bool = False, write_to_file: bool = False, path: str | None = None, token: antimatter.auth.config.tokens.OidcToken | None = None) None#

Add a profile to the AuthConfig with the provided domain ID and API key. If no display name is provided, the domain ID will be used. If write_to_file is set to True, the updated AuthConfig will be written to the file it was loaded from, or the override path.

Parameters:
  • domain_id – The domain ID for the profile

  • api_key – The API key for the profile

  • name – The display name for the profile

  • default_read_context – The default read context

  • default_write_context – The default write context

  • mark_active – If True, mark this profile as active

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file

update_profile(name: str, domain_id: str, api_key: str | None = None, token: antimatter.auth.config.tokens.OidcToken | None = None, default_read_context: str | None = None, default_write_context: str | None = None, write_to_file: bool = False, path: str | None = None)#

Update a profile with the provided domain ID and API key. If write_to_file is set to True, the updated AuthConfig will be written to the file it was loaded from, or the override path.

Parameters:
  • name – The display name of the profile to update

  • domain_id – The domain ID for the profile

  • api_key – The API key for the profile

  • token – The token for the profile

  • default_read_context – The default read context

  • default_write_context – The default write context

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file

add_global_identity(token_type: str, name: str, mark_active: bool = False, write_to_file: bool = False, path: str | None = None, **kwargs) None#

Add a global identity to the AuthConfig with the provided token type, name, and kwargs for initializing the global identity token. If write_to_file is set to True, the updated AuthConfig will be written to the file it was loaded from, or the override path.

Parameters:
  • token_type – The token type for the global identity

  • name – The display name for the global identity

  • mark_active – If True, mark this global identity as active

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file

  • kwargs – The kwargs with which to initialize the global identity token

update_global_identity(name: str, token_type: str, write_to_file: bool = False, path: str | None = None, **kwargs) None#

Update a global identity with the provided token type and kwargs. If write_to_file is set to True, the updated AuthConfig will be written to the file it was loaded from, or the override path.

Parameters:
  • name – The display name of the global identity to update

  • token_type – The token type for the global identity

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file

  • kwargs – The kwargs with which to initialize the global identity token

get_profile(name: str | None = None, domain_id: str | None = None) antimatter.auth.config.profiles.Profile | None#

Get the profile using either the name or domain_id. Name has higher precedence if both are provided. If neither are provided, the active profile will be used.

Parameters:
  • name – The display name of the profile to find

  • domain_id – The domain ID of the profile to find

Returns:

The found profile, or None if not found

mark_profile_active(name: str | None = None, domain_id: str | None = None, write_to_file: bool = False, path: str | None = None) None#

Mark the profile with the given name or domain_id as active. If domain_id is provided, it must be present in the known profiles in order to fetch the name.

Parameters:
  • name – The display name of the profile to mark as active

  • domain_id – The domain ID of the profile to mark as active

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file

get_global_identity(name: str | None = None) antimatter.auth.config.global_identity.GlobalIdentity | None#

Get the global identity with the given name.

Parameters:

name – The name of the global identity to find

Returns:

The found global identity, or None if not found

mark_global_identity_active(name: str, write_to_file: bool = False, path: str | None = None) None#

Mark the global identity with the given name as active.

Parameters:
  • name – The name of the global identity to mark as active

  • write_to_file – If True, overwrite the config file with the updated contents of the AuthConfig

  • path – Override path to the config file