fix: add API key auth to gateway and server-side cache invalidation#118
Merged
fix: add API key auth to gateway and server-side cache invalidation#118
Conversation
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.
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.
Summary
Extends cache invalidation to cover CLI and API calls (not just browser).
Gateway (Rust):
oc_...API key validation toAuthUserextractor, falling back to session cookie authfind_api_keyDB query for theapi_keystableWeb app (TypeScript):
gateway-invalidate.tsutility that forwards request auth headers to the gatewayHow 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.