config.load_config()
Loads and validates Maskinporten credentials.
Usage
config.load_config(
deployment="local",
secret_scope=None,
key_vault_uri=None,
region=None,
project_id=None,
prefix=""
)Parameters
deployment: str = "local"-
Where to read the credentials from: “local” reads the environment variables PRIVATE_KEY, MASKINPORTEN_CLIENT_ID, KID and SCOPE. “azure” reads the Key Vault secrets PRIVATE-KEY, MASKINPORTEN-CLIENT-ID, KID and SCOPE, signing in with DefaultAzureCredential; needs pymaskinporten[azure]. “databricks” reads the same dashed secret names from a Databricks secret scope; needs pymaskinporten[databricks]. “aws” reads the same dashed secret names from AWS Secrets Manager, signing in with boto3’s default credential chain; needs pymaskinporten[aws]. “gcp” reads the same dashed secret names (latest version) from Google Secret Manager, signing in with Application Default Credentials; needs pymaskinporten[gcp].
secret_scope: str | None = None-
The Databricks secret scope. Required for “databricks”.
key_vault_uri: str | None = None-
The Key Vault URL. Required for “azure”.
region: str | None = None-
The AWS region for “aws”. Defaults to boto3’s configured region.
project_id: str | None = None-
The Google Cloud project ID. Required for “gcp”.
prefix: str = ""- Prepended as-is to every environment variable or secret name, e.g. “PROD_” for “local” (reads PROD_KID), “maskinporten/prod/” for AWS or “maskinporten-prod-” for Key Vault. Use characters the source allows.
Returns
MaskinportenSecrets: MaskinportenSecrets- The validated credentials.
Raises
ValueError-
If
deploymentis unknown or its required argument is missing. RuntimeError-
If a credential is missing or can’t be read.
pydantic.ValidationError- If a credential is blank or invalid.
Examples
load_config() load_config(“azure”, key_vault_uri=“https://my-vault.vault.azure.net/”) load_config(“databricks”, secret_scope=“maskinporten”) load_config(“aws”, region=“eu-north-1”, prefix=“maskinporten/prod/”) load_config(“gcp”, project_id=“my-project”, prefix=“maskinporten-prod-”)