keyverify
Shared client for verifying API keys against the central admin key server
(admin-platform /internal/verify-key). Used by every service instance
(asr, ocr, agent, ...) so key verification logic lives in one place.
Use
from keyverify import KeyVerifier
verifier = KeyVerifier(
verify_url="https://admin.internal/internal/verify-key",
service_token="tok_asr_xxx", # this instance's X-Service-Token
scope="cust-A", # the customer this instance serves (optional)
cache_ttl=300, # cache a result for 5 min
fail_open=False, # if central is down and nothing cached: deny
)
result = verifier.verify(incoming_api_key)
if result.valid:
client, tenant = result.client, result.tenant
else:
... # reject with 401; result.reason explains why
Behavior
- Cache: a verified key is cached for
cache_ttlseconds, so the central server is not hit on every request, and a revocation takes effect within that window. - Outage tolerance: if the central server is unreachable, a cached result is
still honored. With no cached result,
fail_opendecides allow vs deny (default deny). - Scope: when
scopeis set, the server rejects keys belonging to other customers (returnsvalid=false, reason="scope_mismatch").
Install (per service)
Each service adds this as a dependency (path, git, or internal index). E.g. in a service's pyproject:
dependencies = ["keyverify @ file:///path/to/key-verify-client"]
Development
Install the project and its development tools:
python -m pip install -e ".[dev]"
npm ci
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit install --hook-type pre-push
Run the same checks used by GitHub Actions:
pre-commit run --all-files
pytest --cov=keyverify --cov-report=term-missing --cov-fail-under=90
python -m build
python -m twine check dist/*
Automated releases
The repository uses Conventional Commits and semantic-release.
- Pull requests and feature branches run linting, type checking, tests, coverage, wheel/source-distribution builds, and package metadata checks.
- Commits pushed to
devcreate a prerelease such as0.2.0-dev.1. The corresponding Python distribution version is normalized to0.2.0.dev1and attached to the GitHub prerelease. - Commits pushed to
maincreate a stable GitHub release and publish the wheel and source distribution to PyPI. - After a stable release, the workflow merges
mainback intodev.
Required GitHub and PyPI settings
- Keep the existing
package-lock.jsoncommitted because the workflows usenpm ci. - Create a GitHub Environment named
pypi. - In the PyPI project, add a GitHub Trusted Publisher with:
- repository owner and repository name matching this repository;
- workflow filename
release.yml; - environment name
pypi.
- Give GitHub Actions permission to create repository contents. If branch
protection prevents the release commit or the
maintodevsynchronization, create a repository secret namedSEMANTIC_RELEASE_TOKENcontaining a fine-grained token that can push to both branches and create releases.
Only stable releases from main are uploaded to PyPI. The dev branch produces
GitHub prereleases only. Package version metadata is stored in
src/keyverify/version.py.
Metadata
Release files for keyverify 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| keyverify-1.0.0.tar.gz | 12.7 MB | With provenance | Details for keyverify-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keyverify-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for keyverify-1.0.0-py3-none-any.whl |
Total release size: 12.7 MB
Release files / keyverify-1.0.0.tar.gz
| Download URL | keyverify-1.0.0.tar.gz |
|---|---|
| Size | 12.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d282fa25103031313a7664e295d066f067b052edda9679d809b706c596ba6192
|
|
BLAKE2b-256 checksum How to use checksums |
f7cc38da721098eac499d89a2e2b110a8cea2d201b0ced47c7dcc10e21bec66d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 30, 2026.
Transparency logRelease files / keyverify-1.0.0-py3-none-any.whl
| Download URL | keyverify-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdaa2bf003b44e231069712e374f8fd4975ee0b83831bc148b18e4da3fc35667
|
|
BLAKE2b-256 checksum How to use checksums |
53144cbb4840cc566955e126ca1ee3b3218625dc3e591e66c6e60ac6e1ab4fb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 Jun 30, 2026.
Transparency logSecurity for keyverify 1.0.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for keyverify-1.0.0.tar.gz
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 Jun 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.