Skip to content

fix: add API key auth to gateway and server-side cache invalidation#118

Merged
guyb1 merged 1 commit intomainfrom
fix/cache-invalidation-api-routes
Mar 26, 2026
Merged

fix: add API key auth to gateway and server-side cache invalidation#118
guyb1 merged 1 commit intomainfrom
fix/cache-invalidation-api-routes

Conversation

@guyb1
Copy link
Copy Markdown
Contributor

@guyb1 guyb1 commented Mar 26, 2026

Summary

Extends cache invalidation to cover CLI and API calls (not just browser).

Gateway (Rust):

  • Add oc_... API key validation to AuthUser extractor, falling back to session cookie auth
  • Add find_api_key DB query for the api_keys table

Web app (TypeScript):

  • Add gateway-invalidate.ts utility that forwards request auth headers to the gateway
  • Call it from all mutation API routes (secrets, rules, agents)

How it works

CLI sends mutation with Authorization: Bearer oc_... → API route saves to DB → forwards auth header to gateway → gateway validates API key, resolves account → clears cache → next agent request gets fresh data.

Add oc_... API key validation to the gateway's AuthUser extractor so
CLI-originated requests can authenticate with the gateway directly.
Falls back to session cookie auth if no API key is present.

Add server-side cache invalidation to all mutation API routes — after
each secret, rule, or agent change, the API route forwards the
caller's auth headers to the gateway's /api/cache/invalidate endpoint.
This ensures CLI mutations trigger immediate cache invalidation,
complementing the existing client-side hook for browser mutations.
@guyb1 guyb1 merged commit 70fdfa8 into main Mar 26, 2026
1 check passed
@guyb1 guyb1 deleted the fix/cache-invalidation-api-routes branch March 26, 2026 20:15
@guyb1 guyb1 mentioned this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant