[Bug] [BanyanDB] MCP HTTP server rejects a lowercase "bearer" Authorization scheme

未关闭
#14,199 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@UchihaIthachi 已经在做这个了。

开始于 2026年11月6日。

  • #1462 来自 @UchihaIthachi —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

bug database
Search before asking
  • I had searched in the issues and found no similar issues.
Apache SkyWalking Component

BanyanDB (apache/skywalking-banyandb)

What happened

While looking at the MCP server after #14194, I tried HTTP mode with a token and noticed that Authorization: bearer <token> (lowercase) gets a 401 even when the token is right. Only the exact Bearer prefix works, because getAuthorizationToken in mcp/src/server/http.ts uses startsWith('Bearer ').

What you expected to happen

The auth scheme name is case-insensitive (RFC 9110 section 11.1, which RFC 6750 uses for Bearer), so bearer or BEARER with the right token should be accepted. Some HTTP clients and proxies send it in lowercase, and a 401 there is confusing because the token itself is correct.

How to reproduce

On main (27349fdf), in mcp/ (BanyanDB doesn't need to be running for this):

TRANSPORT=http MCP_AUTH_TOKEN=secret MCP_PORT=3999 npx tsx src/index.ts &
curl -s -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:3999/mcp \
  -H 'Authorization: bearer secret' -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"ping"}'
# 401
curl -s -o /dev/null -w '%{http_code}\n' -X POST http://127.0.0.1:3999/mcp \
  -H 'Authorization: Bearer secret' -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"ping"}'
# 200
Anything else

Canopy in the same repo already handles this: bearerCredential in canopy/server/src/lib/tokens.ts matches the scheme case-insensitively. So the fix is to do the same in the MCP server, with unit tests for the header parsing. I have it ready and will link the PR here.

Are you willing to submit a pull request to fix on your own?
  • Yes I am willing to submit a pull request on my own!
Code of Conduct
主要语言
Java
星标
25k
派生
6.6k
平均合并
12 小时 57 分钟
30 天内合并 PR
46

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/skywalking 的其他 Issue

查看 apache/skywalking 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。