Skip to main content

Python Wrapper around Infisical SDK with environment validation and helpers to get environment secrets

Project description

Infisical Secrets Wrapper

A clean, Pythonic wrapper around the Infisical SDK with:

  • automatic environment validation
  • client initialisation
  • fetch secrets for a given 'project'
  • fetch a single-secret
  • clean error handling

Purpose

  • A tool for the Homelab'er to use as a unified and simple way to get secrets into python scripts.
  • This is not production grade - Infisical provides methods for that.
  • Keep Dry. Reduces a lot of the verbosity and repetition required for the sdk to reliably pull secrets.
  • Keep Simple.
  • Catch things that go wrong.

Pre-requisites

  • A self-hosted Infisical Server.
  • Universal Auth Credentials for the server.
  • Access to /etc/environment

Installation

pip install infisical-wrapper

Create Infisical Creds

These can be found or created in the Infisical ui at
Access Control/Machine Identities/Create or click Organization Machine Identity/Universal Auth dropdown/
Here you will find Client ID and Client Secret

INFISICAL HOST="http(s)://<host>:<port>"  
INFISICAL_CLIENT_ID= "<YOUR ID>"
INFISICAL_CLIENT_SECRET= "<YOUR SECRET>"

Put these in /etc/environmment to be accessible globally on your node.
Log out and in again.
Alternatively keep them in .env which are picked up on fallback.
These allow the module to reach your Infisical Server.

Usage

from infisical_wrapper import Infisical

mgr = Infisical() # optional mgr = Infisical(debug=True)
client = mgr.init_client()

# Fetch all Secrets for a Project
secrets = mgr.fetch_secrets("my-project")
print(f"\n🔑 Secrets dictionary:\n{secrets}")

# Get a specific Secret for a Project
password = mgr.get_secret("my-project", "prod", "DB_PASSWORD")
print(password)

Limitations

  • Only fetches secrets presently.
  • Future releases will create & update (delete will not be supported).

License

MIT License

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

infisical_wrapper-1.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

infisical_wrapper-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file infisical_wrapper-1.0.2.tar.gz.

File metadata

  • Download URL: infisical_wrapper-1.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for infisical_wrapper-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3760fdd0dba541ec2b76fca2a4855e86c92ce9adc260e313e237a13670ad6718
MD5 69020a07e9a3ed8857019b3c9034a50c
BLAKE2b-256 6eea9fda2744645f6d51b73178d4ddabd57b8400ee162dbd8e7ed9f2da010fcd

See more details on using hashes here.

File details

Details for the file infisical_wrapper-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for infisical_wrapper-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa2f5737ec00cbdb4e3ef3cab715879567bce61a793fa477fe738641e263a6b9
MD5 b490bacf87bcfab7f0c22a495ae2805d
BLAKE2b-256 a0f0538e91c2bb2c9fccb1a9a31a3c37d79f595b742badfc4803f927b2e36e75

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