Repository navigation
feat(cliproxyapi): enable api-keys authentication on Linux only #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c0b61b8
46dae4e
fceb681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -68,6 +68,15 @@ if [ -f "$TEMPLATE" ]; then | |||||||||||||||||||||||||||||||||||||
| -e "s|__ZAI_API_KEY__|${ZAI_API_KEY:-}|g" \ | ||||||||||||||||||||||||||||||||||||||
| -e "s|__AMP_UPSTREAM_API_KEY__|${AMP_UPSTREAM_API_KEY:-}|g" \ | ||||||||||||||||||||||||||||||||||||||
| "$TEMPLATE" >"$CONFIG" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Linux: uncomment and enable api-keys for client authentication | ||||||||||||||||||||||||||||||||||||||
| # macOS: leave api-keys commented for open access | ||||||||||||||||||||||||||||||||||||||
| if [ "$(uname)" = "Linux" ]; then | ||||||||||||||||||||||||||||||||||||||
| @sed@ -i \ | ||||||||||||||||||||||||||||||||||||||
| -e "s|^# api-keys:|api-keys:|" \ | ||||||||||||||||||||||||||||||||||||||
| -e "s|^# - \"__CLIPROXY_API_KEY__\"| - \"${CLIPROXY_API_KEY:-}\"|" \ | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty API key enabled when environment variable unsetWhen |
||||||||||||||||||||||||||||||||||||||
| "$CONFIG" | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Linux this block always uncomments Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+79
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block has two significant issues:
Here is a more robust implementation that addresses both points by first checking for a non-empty key and then safely escaping it before substitution.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| # Also copy to objectstore config location (cliproxyapi uses this for persistence) | ||||||||||||||||||||||||||||||||||||||
| mkdir -p "$CONFIG_DIR/objectstore/config" | ||||||||||||||||||||||||||||||||||||||
| cp "$CONFIG" "$CONFIG_DIR/objectstore/config/config.yaml" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: The API key authentication is enabled unconditionally on Linux without checking if
CLIPROXY_API_KEYis actually set. When the environment variable is empty or unset, the config will containapi-keys: [""], which could either lock out all clients (if empty keys are rejected) or create a security vulnerability (if empty keys are accepted). Add a check for a non-empty key value before enabling authentication.Prompt for AI agents