Fix OAuth token request using full URL as HTTP request path#45
Merged
snoble merged 3 commits intofragment-dev:devfrom Feb 25, 2026
Merged
Conversation
`Net::HTTP::Post.new(uri.to_s)` passes the full URL (e.g. `https://auth.us-east-1.fragment.dev/oauth2/token`) as the HTTP request path instead of just the path component (`/oauth2/token`). This causes the raw HTTP request line to be: POST https://auth.us-east-1.fragment.dev/oauth2/token HTTP/1.1 Some servers (notably AWS Cognito behind CloudFront) do not handle absolute-form request URIs and misroute the request, returning 405 Method Not Allowed. Fix by using `uri.request_uri` which returns just the path and query string components. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Validates the token request against RFC 7230 §5.3.1 (origin-form request-target) and RFC 6749 §4.4.2/§2.3.1 (client credentials grant format, HTTP Basic authentication). Intercepts Net::HTTP::Post to verify the raw request path since WebMock normalizes URLs and cannot detect absolute-form vs origin-form request-targets. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
vigneshwerv
approved these changes
Feb 25, 2026
Contributor
|
Thank you @jacksonhuether |
Merged
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.
Summary
create_tokenpasses the full URL toNet::HTTP::Post.new(uri.to_s), which causes the entire URL (e.g.https://auth.us-east-1.fragment.dev/oauth2/token) to be used as the HTTP request path instead of just/oauth2/token.The raw HTTP request line ends up as:
instead of:
Some servers — notably AWS Cognito behind CloudFront — do not handle absolute-form request URIs and misroute the request, returning 405 Method Not Allowed (
allow: GET).Fix
Replace
uri.to_swithuri.request_uri, which returns just the path and query string (/oauth2/token).