Skip to content

fix: allow cookie auth for admin UI fetch requests#2750

Merged
crivetimihai merged 1 commit intomainfrom
small-fixes
Feb 7, 2026
Merged

fix: allow cookie auth for admin UI fetch requests#2750
crivetimihai merged 1 commit intomainfrom
small-fixes

Conversation

@crivetimihai
Copy link
Copy Markdown
Member

Summary

  • Fix admin UI 401 errors introduced by fix: not authenticate API with Cookies. Returns response 401 instead 200 #2680: The cookie-auth rejection check only recognized text/html Accept headers and HTMX requests as "browser requests", but the admin UI's JavaScript fetch() calls send Accept: */* or application/json — causing all admin panel AJAX requests to fail with Cookie authentication not allowed for API requests.
  • Fix: Also check the Referer header for /admin to correctly identify admin UI fetch calls as legitimate browser-originated requests, while still blocking external API callers using cookie-only auth.
  • Relax flaky test threshold: Lower the unix socket throughput assertion from 50 to 10 calls/sec to prevent intermittent CI failures.

Closes #2680 regression.

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>
@crivetimihai crivetimihai merged commit bc8b764 into main Feb 7, 2026
51 checks passed
@crivetimihai crivetimihai deleted the small-fixes branch February 7, 2026 16:56
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant