stacklok / stacklok/toolhive

Implement token store and caching for exchanged tokens

Open
#2,045 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

authentication enhancement proxy
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Add support in ToolHive proxy for caching and storing exchanged downstream tokens. The goal is to avoid re-exchanging tokens on every call while ensuring tokens are rotated before expiry and never stale.

Key requirements:

  • Support two modes: Per-call mode (no caching, always perform a token exchange), Session caching mode (reuse a token within a session, keyed by {subject_token_hash, audience, scopes}).
  • Implement configurable TTL and proactive rotation (e.g. refresh when 80% of token lifetime has elapsed).
  • Support multiple storage backends: In-memory (default, single-node), Redis (pluggable option for multi-node deployments).
  • Ensure tokens are stored ephemerally only, no persistence beyond configured TTL.
  • Add safeguards: Clear tokens on error or explicit expiry, Redact tokens from logs/metrics.

Tasks:

  • Implement code to perform this caching of tokens
  • [ ] Implement different caching backends (local, redis)
  • Unit tests cover cache hit, miss, expiry, and rotation.
  • [ ] Integration tests for different methods and storage backends
  • [ ] Documentation updates explaining caching strategies, trade-offs, and secure storage practices.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ToolHive proxy path that exchanges downstream tokens and identify how proxy sessions and configuration are represented. Define the boundaries for per-call versus session caching, in-memory versus Redis storage, TTL rotation, and token redaction before implementing. Add unit coverage for cache hits, misses, expiry, and rotation, integration coverage for methods and backends, and document the caching and secure-storage trade-offs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, redis
Domain
backend, security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.