Merged
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe PR introduces API key authentication across the proxy service. It adds a RequiredAPIKeys configuration field with validation, implements an apiKeyAuth middleware that validates API keys from headers, and applies it to all API routes. When configured, requests require valid API keys; when unconfigured, authentication is bypassed. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ProxyManager
participant apiKeyAuth
participant Config
participant UpstreamAPI
rect rgb(200, 220, 255)
Note over Client,UpstreamAPI: Scenario 1: Valid API Key
Client->>ProxyManager: POST /api/chat/completions<br/>x-api-key: valid-key
ProxyManager->>apiKeyAuth: Check authentication
apiKeyAuth->>Config: Load RequiredAPIKeys
Config-->>apiKeyAuth: [key1, key2, ...]
apiKeyAuth->>apiKeyAuth: Validate x-api-key<br/>against configured keys
apiKeyAuth->>apiKeyAuth: Strip auth headers
apiKeyAuth-->>ProxyManager: Pass through (authenticated)
ProxyManager->>UpstreamAPI: Forward request<br/>(no auth headers)
UpstreamAPI-->>ProxyManager: 200 OK
ProxyManager-->>Client: 200 OK
end
rect rgb(255, 220, 200)
Note over Client,UpstreamAPI: Scenario 2: Invalid/Missing API Key
Client->>ProxyManager: POST /api/chat/completions<br/>(no key)
ProxyManager->>apiKeyAuth: Check authentication
apiKeyAuth->>Config: Load RequiredAPIKeys
Config-->>apiKeyAuth: [key1, key2, ...]
apiKeyAuth->>apiKeyAuth: No valid key found
apiKeyAuth-->>ProxyManager: 401 Unauthorized
ProxyManager-->>Client: 401 Unauthorized
end
rect rgb(220, 255, 220)
Note over Client,UpstreamAPI: Scenario 3: Keys Not Configured
Client->>ProxyManager: POST /api/chat/completions
ProxyManager->>apiKeyAuth: Check authentication
apiKeyAuth->>Config: Load RequiredAPIKeys
Config-->>apiKeyAuth: [] (empty)
apiKeyAuth-->>ProxyManager: Pass through (no-op)
ProxyManager->>UpstreamAPI: Forward request
UpstreamAPI-->>ProxyManager: 200 OK
ProxyManager-->>Client: 200 OK
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (8)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Dec 27, 2025
Merged
rohitpaul
pushed a commit
to rohitpaul/llama-swap
that referenced
this pull request
Mar 29, 2026
Add configuration support for api keys that are enforced by llama-swap. Keys are stripped before sending them to upstream servers. Updates: mostlygeek#433, mostlygeek#50 and mostlygeek#251
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.
Add Support for llama-swap level API keys
Updates: #433, #50 and #251
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.