Skip to main content

Tool for managing secrets in Azure Key Vault

Project description

Aleph Secrets Manager

A simple Python tool for managing secrets in Azure Key Vault using a command-line interface (CLI).

You may also use the underlying Azure Key Vault adaptor directly if for instance you want to load secrets into an application programmatically.

Purpose

  • Read, write, and delete secrets in Azure Key Vault from the command line.
  • Supports bulk upload/download from .env files.

Dependencies

Install the following Python packages (see aleph_secrets_manager/requirements.txt):

  • azure-identity
  • azure-keyvault-secrets
  • pydantic
  • python-dotenv

Install dependencies:

pip install -r aleph_secrets_manager/requirements.txt

CLI Usage

Run the CLI from the project root:

Read all secrets from Key Vault and save to a .env file

python cli.py -v <vault-name> read -f .env

Write all secrets from a .env file to Key Vault

python cli.py -v <vault-name> write -f .env

Delete secrets from Key Vault

python cli.py -v <vault-name> delete -k SECRET_1 -k SECRET_2
  • Replace <vault-name> with your Azure Key Vault name.
  • The -f flag specifies the path to your .env file.
  • The -k flag can be repeated for each secret key to delete.

Adaptor Usage

# Initialize the secrets manager
vault_name = "test-kv"
secrets_manager = AzureSecretsManager(AzureClientFactory.create(vault_name))

# Read a secret
secrets_manager.read_secret("SECRET-1")

# Write secret
new_secret = Secret(key="NULL_SECRET", value="test123")
secrets_manager.write_secret(new_secret)

# List all secrets 
secrets_manager.list_all_secrets()

# Read all secrets
secrets_manager.read_all_secrets()

# Download all
env_path = Path().parent.parent / ".env"
secrets_manager.download_all_to_env_file(env_path)

# Upload from .env
secrets_manager.upload_from_env_file(env_path)

# Delete a secret
secrets_manager.delete_secret('SECRET_2')
secrets_manager.delete_secret('SECRET_1')

Authentication

This tool uses Azure's DefaultAzureCredential. Make sure you are authenticated (e.g., via az login) and have access to the Key Vault (e.g. Key Vault Secrets User).


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

aleph_secrets_manager-0.1.1.tar.gz (82.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aleph_secrets_manager-0.1.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file aleph_secrets_manager-0.1.1.tar.gz.

File metadata

  • Download URL: aleph_secrets_manager-0.1.1.tar.gz
  • Upload date:
  • Size: 82.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aleph_secrets_manager-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f92db5cc7b08cd18d3db2769909f812fd611eba32c50e16b68d16a53ebc23549
MD5 f9c76d19f0cb8dafd9a64ffe195f9c11
BLAKE2b-256 1d383c1cfd690cc09276625f49e78e81eb52fb5e75a63c42b5483da8b773622f

See more details on using hashes here.

File details

Details for the file aleph_secrets_manager-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aleph_secrets_manager-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.12 {"installer":{"name":"uv","version":"0.9.12"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Pop!_OS","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for aleph_secrets_manager-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4456d907950d2ca504f05566a944e8b6372da8eaff0b5c92e07f2e73f285d6b1
MD5 bd5295f1097f056957948ee3dc443041
BLAKE2b-256 bd68edd02bda199a700c977a19c637ecf7379036063ef9df1a4abbdd5e5f27bc

See more details on using hashes here.

Supported by

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