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.0.tar.gz (73.9 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.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aleph_secrets_manager-0.1.0.tar.gz
  • Upload date:
  • Size: 73.9 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.0.tar.gz
Algorithm Hash digest
SHA256 19c08c6cdd8c0654d12a4583bb183bc6888382c913f9feed53e6baa194f67348
MD5 f1068dccc594bdfab01edcfeb8ee5ea8
BLAKE2b-256 812d3fec77e0600162c46e41b729d1e886a8c9dc9276a3ef161339a20a1380be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aleph_secrets_manager-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0415d056d9d15b5f055f584d9b704049a18d6718fdb8c2b798626ec07d26802
MD5 8347deddc41c776f1c983e0111749e2d
BLAKE2b-256 8761b03a6c0044228ff61fc705e1f639cda6c75f436f04f8ba2cdf1b98f2c894

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