Repository navigation
Accept HTTP Basic client authentication at the token endpoint - #13
Merged
Merged
Conversation
The token endpoint only read client_id and client_secret from the request body, and the server metadata did not list token_endpoint_auth_methods_supported. Clients then default to client_secret_basic (RFC 8414), which this server rejected with invalid_client. RubyLLM 2.1 does exactly that, so connecting from the AI platform failed. Accept HTTP Basic credentials (RFC 6749 section 2.3.1) alongside the request body, and advertise both methods. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Malformed credentials can cause a 500, and Basic authentication failures omit the required challenge header.
4 open findings
What changed in this PR
Adds HTTP Basic client authentication support to the OAuth token endpoint.
Changes:
- Advertises Basic and POST client authentication methods.
- Parses form-encoded Basic credentials.
- Adds authentication and metadata specs.
| File | Description |
|---|---|
lib/mail_mcp/app.rb |
Implements and advertises Basic authentication. |
spec/mail_mcp/app_spec.rb |
Tests Basic authentication and discovery metadata. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+153
to
+154
| auth = Rack::Auth::Basic::Request.new(request.env) | ||
| return [params[:client_id], params[:client_secret]] unless auth.provided? && auth.basic? |
| auth = Rack::Auth::Basic::Request.new(request.env) | ||
| return [params[:client_id], params[:client_secret]] unless auth.provided? && auth.basic? | ||
|
|
||
| auth.credentials.map { |part| URI.decode_www_form_component(part) } |
Comment on lines
+101
to
+102
| it "accepts client credentials sent with HTTP Basic authentication" do | ||
| basic_authorize URI.encode_www_form_component(client_id), URI.encode_www_form_component(client_secret) |
Comment on lines
+107
to
+108
| redirect_uri: redirect_uri, | ||
| client_id: client_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
POST /oauth/tokenreadclient_idandclient_secretonly from the request body, and/.well-known/oauth-authorization-serverdidn't listtoken_endpoint_auth_methods_supported. Without that field, clients default toclient_secret_basic(RFC 8414) and send the credentials in anAuthorization: Basicheader. The server then saw an empty secret and answered401 invalid_client.RubyLLM 2.1 follows that default, so connecting the Mail connector from the AI platform fails with "Failed to complete OAuth authorization". The older
ruby_llm-mcpgem sent the secret in the body, which is why it worked before.Fix
token_endpoint_auth_methods_supported: ["client_secret_basic", "client_secret_post"].Tests
bundle exec rspec(Ruby 3.4.9): 86 examples, 0 failures. RuboCop: no offenses in the changed files.After merging, this needs a release (1.0.4) and a bump of
mcp/mail/Gemfilein the AI platform.🤖 Generated with Claude Code