Repository navigation
Commit 76d7efb
committed
fix(auth): MCP endpoint accepts a case-insensitive Bearer scheme
The MCP HTTP middleware only accepted an Authorization value starting
with exactly "Bearer ", so a client sending "bearer <token>" (valid per
RFC 9110 §11.1) was rejected — and logged with missing_bearer_token,
the same reason as a request with no header at all, so the two could
not be told apart. The same case-sensitive parse in
EnvironmentAuth.parseBearerToken meant OAuth client tokens (the
ChatGPT-connector path) stayed broken even with the middleware fixed.
The middleware now reads the credential through readBearerCredential,
which matches the scheme case-insensitively and classifies a rejection
as missing_authorization_header, unsupported_authorization_scheme,
missing_bearer_token, or unknown_or_expired_token; the warning carries
that reason and never the credential. parseBearerToken matches the
scheme case-insensitively for MCP client sessions and every other
bearer-authenticated HTTP route.
Failing tests first: on main, "bearer <provider token>" on /mcp
returned 401 (expected 200) and authenticateMcpClient failed with
ServerAuthMissingCredentialError. Both pass with the fix, and the
middleware test asserts the four rejection reasons in order.
Fixes #23710 (upstream).
Model: GLM-5.3 (ZCode)1 parent 6e79211 commit 76d7efb
4 files changed
Lines changed: 82 additions & 19 deletions
File tree
- apps/server/src
- auth
- mcp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
272 | 291 | | |
273 | 292 | | |
274 | 293 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
588 | 588 | | |
589 | 589 | | |
590 | 590 | | |
591 | | - | |
592 | 591 | | |
593 | 592 | | |
594 | 593 | | |
| |||
638 | 637 | | |
639 | 638 | | |
640 | 639 | | |
641 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
642 | 644 | | |
643 | 645 | | |
644 | | - | |
| 646 | + | |
645 | 647 | | |
646 | 648 | | |
647 | 649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
689 | 690 | | |
690 | 691 | | |
691 | 692 | | |
692 | | - | |
693 | | - | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
694 | 702 | | |
695 | 703 | | |
696 | 704 | | |
| |||
759 | 767 | | |
760 | 768 | | |
761 | 769 | | |
762 | | - | |
| 770 | + | |
763 | 771 | | |
764 | 772 | | |
765 | 773 | | |
766 | | - | |
| 774 | + | |
767 | 775 | | |
768 | 776 | | |
769 | 777 | | |
| |||
788 | 796 | | |
789 | 797 | | |
790 | 798 | | |
| 799 | + | |
| 800 | + | |
791 | 801 | | |
792 | 802 | | |
793 | 803 | | |
| 804 | + | |
794 | 805 | | |
795 | 806 | | |
796 | 807 | | |
| |||
799 | 810 | | |
800 | 811 | | |
801 | 812 | | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
802 | 817 | | |
803 | 818 | | |
804 | 819 | | |
805 | 820 | | |
806 | 821 | | |
807 | 822 | | |
808 | 823 | | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
809 | 831 | | |
810 | | - | |
811 | | - | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
156 | 178 | | |
157 | 179 | | |
158 | 180 | | |
159 | 181 | | |
160 | 182 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 183 | + | |
166 | 184 | | |
167 | | - | |
168 | | - | |
| 185 | + | |
| 186 | + | |
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
172 | 190 | | |
173 | | - | |
| 191 | + | |
174 | 192 | | |
175 | 193 | | |
176 | 194 | | |
177 | | - | |
178 | | - | |
| 195 | + | |
| 196 | + | |
179 | 197 | | |
180 | 198 | | |
181 | 199 | | |
| |||
0 commit comments