Commit 8968460
Remove WWW-Authenticate: Bearer challenge from MCP 401 responses
The Bearer challenge (RFC 6750) triggers the MCP 2025 spec's mandatory OAuth
2.0 Protected Resource Metadata discovery flow in compliant clients such as the
GitHub Copilot CLI add-server wizard. The wizard probes /.well-known/*, finds
no authorization server metadata, and falls back to prompting the user for
OAuth client credentials they don't have.
This server uses opaque mcp_... API tokens stored in the database — not OAuth.
Removing the challenge stops compliant clients from entering the OAuth flow
while still returning the correct 401 status for unauthenticated requests.
Update tests: AssertUnauthorizedMcpChallengeAsync now explicitly asserts that
WWW-Authenticate is absent, documenting the intentional behaviour.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 21e1638 commit 8968460
2 files changed
Lines changed: 12 additions & 7 deletions
File tree
- EssentialCSharp.Web.Tests
- EssentialCSharp.Web/Auth
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
212 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
0 commit comments