fix(ollama-proxy): require Bearer token on /api/tags#3353
Conversation
Fixes #3338 Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughThis PR enforces Bearer token authentication on all Ollama auth proxy endpoints, including ChangesAuth Proxy Token Enforcement and Test Alignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
E2E Advisor RecommendationRequired E2E: None Full advisor summaryPi Semantic E2E AdvisorSkipped: No Pi provider credential was available in this workflow environment |
ericksoa
left a comment
There was a problem hiding this comment.
Reviewed current head a926f68. This closes the Ollama auth-proxy /api/* bypass by requiring the Bearer token uniformly, including GET /api/tags, while updating internal liveness probes to treat any HTTP response as reachability. The byte-length guarded timingSafeEqual path also avoids malformed/non-ASCII auth header crashes.\n\nValidated locally with shellcheck on the changed E2E scripts, npm run build:cli, npm run format:check, npm run checks, npx vitest run src/lib/inference/local.test.ts --testTimeout 60000, bash test/e2e-ollama-proxy.sh, and an ad hoc non-ASCII auth-header probe. Required GitHub checks are green.
Summary
Remove the unauthenticated bypass for
/api/tagson the Ollama auth proxy: every endpoint (both the OpenAI-compat/v1/*namespace and the Ollama-native/api/*namespace) now requires the Bearer token, matching DevTest T5987914.Related Issue
Fixes #3338
Changes
scripts/ollama-auth-proxy.js: drop the/api/tagsexemption — every request is gated by the same Bearer-token check. Compare buffers (not JS string length) beforecrypto.timingSafeEqualso a non-ASCIIAuthorizationheader can't crash the proxy.curl -sf .../api/tags: since an alive proxy now answers 401 to unauthenticated probes, they now accept any 3-digit HTTP code as proof of life (only000means dead).src/lib/inference/local.tscontainer reachability probe (+ test fixture).test/e2e-ollama-proxy.shandtest/e2e/test-ollama-auth-proxy-e2e.shliveness probes + the post-kill "is it dead" check (flipped because 401 no longer distinguishes alive-vs-dead under-sf).test/e2e/test-gpu-e2e.shandtest/e2e/test-gpu-double-onboard.shproxy-port probes.docs/inference/use-local-inference.md: document that every proxy endpoint requires the Bearer token and that internal reachability checks treat any HTTP response — including 401 — as alive.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)Signed-off-by: Tinson Lai tinsonl@nvidia.com
Summary by CodeRabbit
Documentation
Bug Fixes
Tests