Repository navigation
Conversation
llm.transcript.redis.auth and llm.transcript.audit.postgres.auth take password (the default, unchanged) or a token source. With a source, each new connection signs in as the store's user with a short-lived token made from the identity the deployment already gives the process, so nothing is stored or rotated. Proposed in Accenture#96. The stores know only a user and a token (StoreToken: cached, renewed a minute before it expires). A source is a function in TOKEN_SOURCES that receives the store's endpoint, so another cloud's source joins without a change to the stores. - Redis: redis-py's credential provider returns the user and a current token at each connection. - PostgreSQL: psycopg_pool's callable kwargs give each new connection a current token as its password (psycopg-pool 3.3 or later). - Checks every source shares, at start and by name: a user, no password beside the token, TLS. - The first source, aws: an IAM authentication token presigned locally from the AWS credential chain, which Amazon ElastiCache and Amazon RDS for PostgreSQL accept for 15 minutes; llm.transcript.redis.aws.cache names the replication group; the aws extra adds boto3. Tests: tests/test_llm_store_auth.py pins the ElastiCache token against botocore's RequestSigner with fixed credentials and a fixed clock, the RDS token's form, the renewal, a made-up source signing in both stores, both stores' construction and every refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oken (Accenture#96) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #96: the Python helper, with AWS as the first cloud. The Node.js twin and the other clouds follow in separate changes.
What
The LLM helper's two stores, the transcript store (Redis) and the transcript audit store (PostgreSQL), can sign in with a short-lived token instead of a stored password.
llm.transcript.redis.authandllm.transcript.audit.postgres.authtakepassword(the default, unchanged) or the name of a token source. The first source isaws: an IAM authentication token for Amazon ElastiCache and Amazon RDS for PostgreSQL, presigned locally from the AWS credential chain.Why
The helper already signs its Bedrock calls with the identity the deployment gives the process (a pod's role, a task role, an instance profile). Its stores still needed a password that someone stores, rotates and hands to it. Managed Redis and PostgreSQL on AWS, Google Cloud and Azure all accept a token from the workload's identity instead (#96 compares the three). With this change, a deployment on AWS needs no secret for the helper at all.
Description
A cloud-neutral seam. The stores know only a user and a token. They don't know which cloud made it.
StoreTokencaches a token and renews it a minute before it expires, so a burst of new connections signs once. The asynchronous path signs in a worker thread.store_token()makes the checks every source shares: a username, no password beside the token, and TLS.TOKEN_SOURCESthat receives aStoreEndpoint(store kind, settings prefix, host, port, user) and returns aStoreToken. Another cloud's source is added there without a change to the stores. A test registers a made-up source and signs in to both stores with it.How each store takes the token.
psycopg_pool'skwargsbecomes a function, so each new pooled connection gets a current token as its password. A pool takes a function from psycopg-pool 3.3 on, so with a token source the helper checks for 3.3 at start. Thepostgresextra still allows 3.2 for password users.The source
aws.connectfor the user on the replication groupllm.transcript.redis.aws.cache, presigned with SigV4 forelasticacheand valid 900 seconds, without its scheme. This is AWS's documented form.generate_db_auth_tokenfor the host and port.Neither call reaches the network. The region is
llm.aws.region, else the AWS environment. A newawsextra adds boto3, for deployments that use the token without Bedrock.Refused at start, by name: a missing user, a password beside the token, TLS off, and for
awsa missing cache name, region or boto3. For example:llm.transcript.redis.auth aws needs llm.transcript.redis.username - the user the token signs in.Files:
extensions/llm-helper/llm_helper.py;tests/test_llm_store_auth.py(24 tests); the helper's README ("Signing in to the stores with a token" and the configuration table); the sampleresources/application.yml;pyproject.toml(theawsextra);CHANGELOG.md(Unreleased); a session log and the threadstore-token-sign-in.Known limitations
ResourceType=ServerlessCache, and it offers only a cluster endpoint, which the helper's client (single server) cannot use.AUTH) before their token expires. The seam renews tokens for new connections only, so the Azure source would add that.redis>=5.botocore.auth), as it already does for the Bedrock calls. Keep that logger above DEBUG where tokens matter. This is documented in the README.store-token-sign-in).How to test
1. Unit tests (no network, no AWS account)
Setup:
uv venv .venv && uv pip install -e '.[dev]'Steps:
Expected result:
24 passedfor the new file; the full suite3040 passed, 76 skipped; ruff clean; basedpyright0 errors. The ElastiCache token test compares the helper's token with botocore'sRequestSignerpresign, using fixed credentials and a fixed clock.2. The start-up checks (no network, no AWS account)
Steps:
Then run it again with the settings complete:
Expected result: the first run stops with
llm.helper cannot start - llm.transcript.redis.auth aws needs llm.transcript.redis.username - the user the token signs in. The second starts:Event API service started on port 9481. It connects on the first loop turn, so it needs no Redis to start.3. Live on AWS (signs in to real stores)
Setup:
aws elasticache create-user --user-id llm-helper --user-name llm-helper --engine valkey --authentication-mode Type=iam --access-string "on ~transcript:* +@all"), in a user group attached to the replication group.CREATE USER llm_helper; GRANT rds_iam TO llm_helper;, the schemaextensions/llm-helper/schema/postgres.sqlapplied, and the role granted what the schema's comments give the writer.elasticache:Connecton the replication group and the user, andrds-db:connectonarn:aws:rds-db:<region>:<account>:dbuser:<DbiResourceId>/llm_helper. Run it inside the VPC (on EKS with Pod Identity, ECS, or EC2), withpip install -e '.[llm,bedrock,redis,postgres,aws]'.Steps: in
extensions/llm-helper, save this ascheck_stores.pyand run it with the settings as-Doptions, as formercury-serve:Then run the helper itself with the same settings and the Bedrock backend, and drive one agent loop turn (
llm.chatwithtools) from an engine.Expected result:
redis: Noneandpostgres: set(), with no authentication error.transcript:<conversation>in Redis and in thetranscript_turntable.elasticache:Connectfrom the role. A new connection then fails with an authentication error, and a loop turn answers503 transcript store unreachable.CLIENT KILLfor the helper's user). The next turn reconnects with a new token.Co-Authored-By: Claude Code noreply@anthropic.com
🤖 Generated with Claude Code