fix: support custom URI schemes in OAuth client registration#181
Merged
taylorotwell merged 9 commits intoMar 26, 2026
Merged
Conversation
Native desktop OAuth clients (Cursor, VS Code, Claude Desktop) use private-use URI schemes (RFC 8252) for redirect callbacks. The 'url' validation rule in OAuthRegisterController rejects these because PHP's filter_var(FILTER_VALIDATE_URL) only accepts http(s):// schemes. Additionally, validation errors return HTML redirects instead of JSON when the client sends Accept: */*. - Add opt-in 'allowed_custom_schemes' config option to mcp.php - Replace 'url' rule with custom closure supporting configured schemes - Use Validator::make() to guarantee JSON 422 responses on failure - Add tests for custom scheme handling and JSON error format Fixes laravel#173 Made-with: Cursor
8ad5945 to
95827f4
Compare
pushpak1300
approved these changes
Mar 26, 2026
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
Fixes #173
Native desktop OAuth clients (Cursor IDE, VS Code, Claude Desktop) use private-use URI schemes (RFC 8252) like
cursor://for redirect callbacks. The currenturlvalidation rule inOAuthRegisterControllerrejects these because PHP'sfilter_var(FILTER_VALIDATE_URL)only acceptshttp(s)://schemes. Additionally, validation errors return HTML redirects instead of JSON when the client sendsAccept: */*.Changes
config/mcp.php— Addallowed_custom_schemesconfig array (empty by default, opt-in). Developers explicitly whitelist the schemes they need, preserving strict MCP spec compliance by default.OAuthRegisterController— Replace theurlrule with a custom closure that accepts URIs whose scheme is inallowed_custom_schemes(validating that a host component is present), and falls back to standardfilter_varURL validation otherwise. Replace$request->validate()withValidator::make()to guarantee a JSON 422 response regardless of theAcceptheader.RegistrarTest— 7 new Pest test cases covering custom scheme acceptance/rejection, edge cases, and the JSON error format fix.Design decisions
allowed_custom_schemespreserves strict MCP spec compliance. No behavioral change for existing users.Validator::make()+ manualresponse()->json()guarantees 422 JSON regardless ofAcceptheader, fixing the HTML redirect bug.redirect_domainsvalidation since domain semantics don't apply to private-use URI schemes.Test plan
cursor://,vscode://,claude://)Accept: */*headerMade with Cursor