Skip to main content

tai42-identity-redis

License: Apache 2.0

The Redis-backed api-key identity provider for the TAI ecosystem — an installable plugin that registers itself as the "redis" identity provider and resolves an inbound api key to an authenticated identity.

Importing the package registers the provider in tai42-kit's module-level identity-provider registry (tai42_kit.access_control.registry, register_identity_provider("redis", ...)), with no tai42_app handle involved — so it registers in any process that imports it, including ones that never start(). A deployment selects it by including redis in the access-control auth_providers list.

Its only tai-* dependencies are tai42-contract (the identity ABCs) and tai42-kit (the registry it registers through, the Redis client, the hash typing seams, and the api-key hash). It never imports the skeleton — the plugin is contract-facing, and the import is banned by ruff.

The TAI ecosystem

TAI is an open-source runtime for MCP tools, agents, and workflows. An identity provider is how the runtime answers "who is this caller?": it resolves an inbound credential to an authenticated identity, and access control decides what that identity may do. This package is one such provider (api keys over Redis); any package can back the same contract, so this repo is this provider's own full doc home, and the documentation site covers the platform-level story:

What it stores

The provider owns the whole api-key identity record in its own plain-Redis storage:

  • ac:key:{sha256(raw)} — a Redis hash {"user_id", "owner_user_id", "description"} (the identity a raw key resolves to). Every api key belongs to a principal, so every record carries the owner_user_id owner claim.
  • ac:management:key:{user_id} — the user_id -> hash reverse lookup, so a user id resolves to its stored hash for revoke/edit without a scan.

Key material is never stored — only the SHA-256 hash of the raw key.

Surface

The provider implements tai42_contract.access_control.identity.ApiKeyIdentityProvider:

Method Does
validate_token(token) Reads ac:key:{hash} and returns the AuthIdentity, or None for an unknown token. A backend error fails closed by raising; a resolved record carrying no owner claim is an invariant breach and is refused loudly (fail-closed), never resolved.
provision(user_id, description, *, owner_user_id) Mints a raw sk-… key, writes the identity record + reverse lookup in one transaction, and returns the raw key (surfaced once). owner_user_id is required — every api key belongs to a principal — and is stored on the record as the owner claim, so validate_token surfaces it for per-request attenuation. A None/empty owner is a ValueError raised before any write.
revoke(user_id) Deletes the identity record + reverse lookup; False if the user is unknown.
update_description(user_id, description) Rewrites the record's description; False if the user is unknown. A present record carrying no owner claim is refused loudly.
list_identities() SCANs ac:key:* and returns every stored (user_id, description); an enumerated record carrying no owner claim is an invariant breach and is refused loudly.
healthcheck() Probes the provider's OWN Redis storage; raises loudly if the record store is unreachable or broken.

Requirements

Requires Python 3.13+ and any plain Redis — no modules required. The identity records are plain Redis hashes, so redis, valkey, or any module-less redis-server works. An unreachable or broken store is caught loudly by healthcheck() at startup rather than failing per-request.

Install

Requires Python 3.13+. Install from PyPI into the environment that runs the server:

uv add tai42-identity-redis

Or from source — clone this repo and add it as an editable dependency; the tai42-* dependencies resolve in-tree from the workspace.

git clone https://github.com/tai42ai/tai42   # next to your app checkout
cd /path/to/your/app
uv add --editable ../tai42/plugins/identity-redis

Development

uv venv --python 3.13
uv pip install --no-sources --editable ".[dev]"
uv run --no-sync ruff check .
uv run --no-sync ruff format --check .
uv run --no-sync pyright
uv run --no-sync pytest --cov --cov-report=term-missing

License

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for tai42-identity-redis 6.0.0

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

Source distribution (sdist)

Source distribution for tai42-identity-redis 6.0.0
File Size Uploaded Provenance Actions
tai42_identity_redis-6.0.0.tar.gz 17.6 kB Without provenance Details for tai42_identity_redis-6.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tai42-identity-redis 6.0.0
File Interpreter ABI Platform Actions
tai42_identity_redis-6.0.0-py3-none-any.whl Python 3 none any Details for tai42_identity_redis-6.0.0-py3-none-any.whl

Total release size: 34.2 kB

Release files / tai42_identity_redis-6.0.0.tar.gz

Download URL tai42_identity_redis-6.0.0.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
960823d9a4fcdf0d5c60027576100a63a18956278295b0195a7eab78e5c62253
BLAKE2b-256 checksum
How to use checksums
d145fe5f043de6857db38a70c6ebadbb1f7fe67953dec3fd7c750f5b0d92111b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / tai42_identity_redis-6.0.0-py3-none-any.whl

Download URL tai42_identity_redis-6.0.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ea3c1e99a7c9e061e03cee7158ccaf02d9d71bf731dbe04d891259ef4547006
BLAKE2b-256 checksum
How to use checksums
0d8701af51547346ce88efc8ade40b1b099d396c54c7f5d7febcedf81e1fbe5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for tai42-identity-redis 6.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

6.0.0 This release

2 release files No provenance

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