msticpy.auth.azure_auth module
Azure authentication handling.
- msticpy.auth.azure_auth.az_connect(auth_methods: list[str] | None = None, tenant_id: str | None = None, *, silent: bool = False, cloud: str | None = None, **kwargs) AzCredentials
Connect to Azure SDK/API.
- Parameters:
auth_methods (List[str], optional) – List of authentication methods to try For a list of possible authentication methods use the list_auth_methods function. Default is [“env”, “msi”, “vscode”, “cli”, “powershell”, “devicecode”]
tenant_id (str, optional) – The tenant to authenticate against. If not supplied, the default tenant for the identity will be used.
silent (bool, optional) – Set True to hide all output during connection, by default False
credential (AzureCredential) – If an Azure credential is passed, it will be used directly.
cloud (str, optional) – What Azure cloud to connect to. By default it will attempt to use the cloud setting from config file. If this is not set it will default to Azure Public Cloud
- Returns:
Named tuple of: - legacy (ADAL) credentials - modern (MSAL) credentials
- Return type:
- Raises:
MsticpyAzureConnectionError – If chained token credential creation fails.
See also
list_auth_methods
- msticpy.auth.azure_auth.az_user_connect(tenant_id: str | None = None, *, silent: bool = False) AzCredentials
Authenticate to the SDK using user based authentication methods, Azure CLI or interactive logon.
- Parameters:
tenant_id (str, optional) – The tenant to authenticate against. If not supplied, the default tenant for the identity will be used.
silent (bool, optional) – Whether you want the auth process to display any output, by default False
- Returns:
AzCredentials - Dataclass combining two types of Azure credentials
- legacy (ADAL) credentials
- modern (MSAL) credentials
- msticpy.auth.azure_auth.fallback_devicecode_creds(cloud: str | None = None, tenant_id: str | None = None, region: str | None = None) AzCredentials
Authenticate using device code as a fallback method.
- Parameters:
cloud (str, optional) – What Azure cloud to connect to. By default it will attempt to use the cloud setting from config file. If this is not set it will default to Azure Public Cloud
tenant_id (str, optional) – The tenant to authenticate against. If not supplied, the tenant ID is read from configuration, or the default tenant for the identity.
- Returns:
AzCredentials - Dataclass combining two types of Azure credentials
- legacy (ADAL) credentials
- modern (MSAL) credentials
- Raises:
MsticpyAzureConnectionError – If chained token credential creation fails.
- msticpy.auth.azure_auth.get_default_resource_name(resource_uri: str) str
Get a default resource name for a resource URI.