feat: cache upstream bearer tokens #92

Merged
benvin merged 1 commits from benvin/cache-bearer-tokens into master 2026-07-02 21:35:46 +10:00
Owner

Fixes #77

Why

Each upstream 401 re-ran the full token-endpoint request, even though a single Docker pull triggers many blob/manifest requests sharing one scope.

Changes

  • Add Redis GetToken/SetToken.
  • fetchBearerToken now also parses expires_in and returns a TTL.
  • New Engine.cachedBearerToken reuses a cached token keyed by remote + challenge (hashed), caching for expires_in minus a safety margin (default 60s when absent).

Validation

  • make e2e passes.
Fixes #77 ## Why Each upstream 401 re-ran the full token-endpoint request, even though a single Docker pull triggers many blob/manifest requests sharing one scope. ## Changes - Add Redis `GetToken`/`SetToken`. - `fetchBearerToken` now also parses `expires_in` and returns a TTL. - New `Engine.cachedBearerToken` reuses a cached token keyed by remote + challenge (hashed), caching for `expires_in` minus a safety margin (default 60s when absent). ## Validation - `make e2e` passes.
unkinben added 1 commit 2026-07-02 00:42:50 +10:00
feat: cache upstream bearer tokens in Redis
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
493b3cb906
Each upstream 401 re-ran the full token-endpoint dance. Cache the minted
token keyed by remote + challenge, honouring the token's expires_in (with
a safety margin, defaulting to 60s), so subsequent blobs sharing a scope
reuse it.

Refs #77
benvin merged commit e7027c8ccc into master 2026-07-02 21:35:46 +10:00
benvin deleted branch benvin/cache-bearer-tokens 2026-07-02 21:35:47 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/artifactapi#92