Skip to content

fix: strip "token " prefix in multi-user mode#4

Open
zfsone wants to merge 1 commit intoraohwork:masterfrom
zfsone:fix/multi-user-token-prefix
Open

fix: strip "token " prefix in multi-user mode#4
zfsone wants to merge 1 commit intoraohwork:masterfrom
zfsone:fix/multi-user-token-prefix

Conversation

@zfsone
Copy link
Copy Markdown

@zfsone zfsone commented Mar 22, 2026

Summary

  • In multi-user mode (no --token flag), the server reads the Authorization header from each client request
  • The Bearer prefix is correctly stripped, but the token prefix (which is what Forgejo's API docs recommend: Authorization: token <value>) is not
  • This causes the raw string token abc123 to be passed to NewClient, which then sets Authorization: token token abc123 — double prefix, silent auth failure
  • Adds token prefix stripping alongside the existing Bearer handling

Test plan

  • Start server in multi-user mode (forgejo-mcp http --server <url> --address :8080)
  • Send request with Authorization: token <valid-token> header
  • Verify API calls succeed (e.g. list_my_repositories)
  • Verify Authorization: Bearer <token> still works

🤖 Generated with Claude Code

In multi-user mode, the server extracts the token from the client's
Authorization header. It correctly strips the "Bearer " prefix, but
does not strip the "token " prefix that Forgejo's own API documentation
recommends (Authorization: token <value>).

This causes the token to be passed as "token abc123" to NewClient,
which then sets the header to "Authorization: token token abc123",
resulting in silent authentication failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.

2 participants