fix: allow cookie auth for admin UI fetch requests#2750
Merged
crivetimihai merged 1 commit intomainfrom Feb 7, 2026
Merged
Conversation
PR #2680 introduced a check that rejects cookie-only authentication for API requests to prevent CSRF-style attacks from external callers. However, the admin UI's JavaScript fetch() calls (fetchWithTimeout, etc.) send Accept: */* or application/json — not text/html — so they were incorrectly rejected with 401 Unauthorized. Fix by also checking the Referer header for /admin to identify requests originating from the admin UI. The browser automatically sets this header on same-origin fetch calls, so admin UI AJAX requests are correctly recognized as legitimate while external API callers without an admin Referer are still blocked. Also relax the unix socket throughput test threshold (50 → 10 calls/sec) to prevent flaky failures in CI/slow environments. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
PR IBM#2680 introduced a check that rejects cookie-only authentication for API requests to prevent CSRF-style attacks from external callers. However, the admin UI's JavaScript fetch() calls (fetchWithTimeout, etc.) send Accept: */* or application/json — not text/html — so they were incorrectly rejected with 401 Unauthorized. Fix by also checking the Referer header for /admin to identify requests originating from the admin UI. The browser automatically sets this header on same-origin fetch calls, so admin UI AJAX requests are correctly recognized as legitimate while external API callers without an admin Referer are still blocked. Also relax the unix socket throughput test threshold (50 → 10 calls/sec) to prevent flaky failures in CI/slow environments. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
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
text/htmlAccept headers and HTMX requests as "browser requests", but the admin UI's JavaScriptfetch()calls sendAccept: */*orapplication/json— causing all admin panel AJAX requests to fail withCookie authentication not allowed for API requests.Refererheader for/adminto correctly identify admin UI fetch calls as legitimate browser-originated requests, while still blocking external API callers using cookie-only auth.Closes #2680 regression.