Skip to main content

Pydantic extention to work with Azure Key Vaults

Project description

pydantic-azure-secrets

A class to use pydantic settings together with Azure KeyVault

tests

The behaviour of the class is exactly like in pydantic.BaseSettings, except the step which checks azure key vault:

settings_args > envs > dotenv > secret_directory > azure_keyvault > defaults

Install:

pip install pydantic-azure-secrets

Example:

# Example for GitHub REST API

from pydantic import HttpUrl, SecretStr
from pydantic_azure_secrets import AzureVaultSettings


class GitHubBasic(AzureVaultSettings):
    url: HttpUrl = "https://api.github.com/user"
    username: str
    token: SecretStr

    class Config:
        env_prefix = "github_" 
        azure_keyvault = <your_keyvault_URI> # e.g. "https://pydantic-test-kv.vault.azure.net/"

github_settings = GitHubBasic()
# GitHubBasic(url=HttpUrl('https://github.com', scheme='https', host='github.com', tld='com', host_type='domain'), username='kewtree1408', token=SecretStr('**********'))

See more examples in the example.py

Authentification

Authentification for azure keyvault is the same as for SDK

Before using the library, please log in to your Azure subscription with one of the following methods

  • az login
  • environment variables: AZURE_CLIENT_ID, AZURE_CLIENT_PASSWORD, AZURE_TENANT_ID see more

Run tests

tox

TODO:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic-azure-secrets-0.1.0.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

pydantic_azure_secrets-0.1.0-py3-none-any.whl (7.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page