HashiCorp Vault for GitHub Apps
Python library for using HashiCorp Vault's Transit Engine to manage a GitHub App's private RSA key. More precisely, the library provides the following pieces of functionality.
- Perform initial one-way import of the App's private key into Vault
- Issue (short-lived) GitHub Access Token
- Have Vault sign a JWT using the App's private key
- Exchange that JWT for a GitHub Access Token
Conceptually Vault here fills the role of an HSM or a Cloud KMS.
See Authenticating as a GitHub App installation (GitHub Docs) for context.
The library is also tested against OpenBao.
Installation
pip install hv4gha
Usage
In addition to the examples below see also the hv4gha/entry.py docstrings.
Import App key
from hv4gha import import_app_key
with open("/path/to/github-app.private-key.pem", "r") as akh:
my_app_key = akh.read()
response = import_app_key(
pem_key=my_app_key,
key_name="my-github-app",
vault_addr="https://vault.example.com:8200",
vault_token="...",
)
key_version = response["key_version"]
Issue Access Token
from hv4gha import issue_access_token
response = issue_access_token(
key_name="my-github-app",
vault_addr="https://vault.example.com:8200",
vault_token="...",
app_client_id="Iv1.bc01362e9d72c72a",
account="andreaso",
)
access_token = response["access_token"]
token_expiry = response["expires_at"]
Issue scoped Access Token
from hv4gha import issue_access_token
response = issue_access_token(
key_name="my-github-app",
vault_addr="https://vault.example.com:8200",
vault_token="...",
app_client_id="Iv1.bc01362e9d72c72a",
account="andreaso",
permissions={"contents": "read"},
repositories=["world-domination"],
)
access_token = response["access_token"]
token_expiry = response["expires_at"]
Vault requirements
Somewhat simplified, this is what's required Vault wise.
Transit secrets engine
First of all, the Transit Engine needs to be enabled.
vault secrets enable transit
Here we are sticking to the default transit/ mount point.
Import policy
path "transit/wrapping_key" {
capabilities = ["read"]
}
path "transit/keys/my-github-app" {
capabilities = ["read"]
}
path "transit/keys/my-github-app/import" {
capabilities = ["update"]
}
path "transit/keys/my-github-app/import_version" {
capabilities = ["update"]
}
Issue policy
path "transit/sign/my-github-app" {
capabilities = ["update"]
}
Vault Token
For obtaining the initial Vault Token, see the hvac Python library and its Auth Methods documentation.
Metadata
Release files for hv4gha 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hv4gha-0.5.0.tar.gz | 9.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hv4gha-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.8 kB
Release files / hv4gha-0.5.0.tar.gz
| Download URL | hv4gha-0.5.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ce15aaa4b60b96c251706d1e84e71336f88e042dd4c747df8524e874e895602c
|
|
BLAKE2b-256 checksum How to use checksums |
78d7edae80b0487e37305dfe7ff45a4fa20eeeee8a684ef2c7da322a05ce2e5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency logRelease files / hv4gha-0.5.0-py3-none-any.whl
| Download URL | hv4gha-0.5.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07440d8ce890c06315f874406aa16fe00c00c7fe55c50f9e9ce236e1027896ca
|
|
BLAKE2b-256 checksum How to use checksums |
992304debfab73d1a58629eb90765b490965e3d049005e747f9e87c88ae46c37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.
Transparency log