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)

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.1.tar.gz (5.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.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: infisical_wrapper-1.0.1.tar.gz
  • Upload date:
  • Size: 5.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.1.tar.gz
Algorithm Hash digest
SHA256 10c708dcef526b509709fdfeab883761ac6125aec9c2d2de3abb50c79184637e
MD5 61559384620f71d5ca214165a2a87811
BLAKE2b-256 3a3130e2726e5a3b9bd4f4ff4711561b80e010d6e404eb5604016f69fb90929f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for infisical_wrapper-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b068b1f78da9a80af9b1fe0446ee47f3e627664beb3a57b05aaa1a5aa29cc73
MD5 3983da1023c09d3958f8f2d970254072
BLAKE2b-256 f501a09e46577e9731df43933d6a2eb95231e7d76140e29cd2623a51b7517a2f

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