Skip to main content

Secret Template Renderer

This project is a Jinja template renderer that supports fetching secrets from various providers.

Features

  • Load built-in and user-defined plugins to extend the functionality
  • Register multiple secret providers
  • Render Jinja templates with secrets

Installation

Using pip

  1. Clone the repository

  2. Install the required dependencies

    pip install -r requirements.txt
    

Using pipx

pipx install secret_template_renderer

Usage

Template Utilities

  • import_env: import dotenv file
  • get_secret: retrieve secret via secret providers
  • shell: execute shell command
  • random: generate a random string with the following parameters:
    • length: int = 16,
    • type: string | password = 'string',
    • lower_case: bool = True,
    • numbers: bool = True,
    • has_special_chars: bool = False,
    • must_has_special_chars: bool = False,
    • exclude_characters: str = "",

Command Line Interface

  • -d, --debug: Enable debug mode

Generate

str generate [-f <template_path>] [-o <output_path>] [-i <input_string>] [-p <password>]
  • -f, --file: Path to the Jinja template file
  • -o, --output: Path to the output file
  • -i, --input: Input string to be rendered
  • -p, --password: Password to be used for encryption

Encryption

str encrypt|decrypt [-f <template_path>] [-o <output_path>] [-i <input_string>] [-p <password>]
  • -f, --file: Path to the Jinja template file
  • -o, --output: Path to the output file
  • -i, --input: Input string to be rendered
  • -p, --password: Password to be used for encryption

Example

{{ import_env('.default.env') }} # Importing another dotenv file
DATABASE_PWD={{ get_secret('bitwarden', 'database_system_a', 'login.password') }} # Use the bitwarden plugins to load Bitwarden
NAME=app-{{ random(10) }} # Generate the randomised strings
PWD={{ decrypt("SfB505whBisKznrdHKLvQ0hhaESDP0MqvWFsYNkI0to=", "password") }}
UID={{ shell('echo $UID') }}

Custom plugins

To load custom plugins, place your plugin .py files in ~/.config/temv/plugins/[plugin_type]/[plugin_name]. Currently, there are 2 plugins: secrets and encryptions.

Each plugin must have a register function that takes a dictionary of secret providers as an argument.

Secret example:

import subprocess
from collections.abc import Callable


def get_custom_secret(item_name: str, path: str) -> str | None:
    pass


def register(secrets_providers: dict[str, Callable[[str, str], str | None]]):
    """Register secret provider."""
    secrets_providers["custom_provider"] = get_custom_secret

Encryption example:

import subprocess
from collections.abc import Callable


def encrypt(value: str, password: str) -> str | None:
    pass


def decrypt(value: str, password: str) -> str | None:
    pass


def register(providers: dict[str, Callable[[str, str], str | None]]):
    """Register encryption provider."""
    providers["custom_provider"] = {"encrypt": encrypt, "decrypt": decrypt}

License

This project is licensed under the MIT License.

Metadata

Release files for secret_template_renderer 0.2.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for secret_template_renderer 0.2.6
File Size Uploaded
secret_template_renderer-0.2.6.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for secret_template_renderer 0.2.6
File Interpreter ABI Platform
secret_template_renderer-0.2.6-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / secret_template_renderer-0.2.6.tar.gz

Download URL secret_template_renderer-0.2.6.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
648e8a4342639703cda8d273185cbe7ac7ed53a80831d529a203b3cfbf634b09
BLAKE2b-256 checksum
How to use checksums
ce2bb4a9fdf61795d4d609da9695b3aa4648c7b74de6570bbe0fc17e714156c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / secret_template_renderer-0.2.6-py3-none-any.whl

Download URL secret_template_renderer-0.2.6-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e302b9a90c5e43f8305b1d4fe0a4a40b0e22d6f776bf5d58b67b6c4dfeb59437
BLAKE2b-256 checksum
How to use checksums
d0631f68f40c4b2186593efa4d8d1bfedf5abb73d3b90ee27ac4e645cb4bc9a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.6 This release

2 release files

0.2.3

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page