forked from marfrit/lmcp
fix: case-insensitive Bearer token parsing in auth header #1
Reference in New Issue
Block a user
Delete Branch "fix/case-insensitive-bearer-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The MCP authentication header only matches uppercase
Bearer. Some HTTP clients (e.g. certain Go libraries, Python urllib with certain helpers, misconfigured proxies) sendauthorization: bearer <token>(lowercase). This causes a 401 rejection even though the token is valid.Fix
Changed the regex from
^Bearerto^[Bb]earerto accept bothBearerandbeareras valid auth schemes.This was tested locally on the hertz production server — all four header case combinations (
authorization/Authorization×Bearer/bearer) now return HTTP 200.Closes #21
Pull request closed