fix: allow custom URI schemes in OAuth Dynamic Client Registration #2286
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.
What kind of change does this PR introduce?
Bug fix - Fixes OAuth Dynamic Client Registration to support custom URI schemes
What is the current behavior?
Issue: #2285
The OAuth 2.0 Dynamic Client Registration endpoint (
POST /oauth/clients/register) rejects custom URI schemes (e.g.,cursor://,exp://,myapp://) even when they are explicitly whitelisted in theadditional_redirect_urlsconfiguration orGOTRUE_URI_ALLOW_LISTenvironment variable.Current Error
{ "code": 400, "error_code": "validation_failed", "msg": "400: invalid redirect_uri 'cursor://anysphere.cursor-mcp/callback': scheme must be HTTPS or HTTP (localhost only)" }Root Cause
The OAuth server's client registration logic uses strict validation that only allows
httpandhttpsschemes, which is inconsistent with PR #711 that relaxed this validation for general auth flows to support native applications.What is the new behavior?
The OAuth server now uses the same allow-list-based validation as the rest of the auth system (introduced in PR #711). Custom URI schemes work when explicitly configured in the allow list.
Test Results
All validation tests pass successfully:
![Test Results]



Additional context
Changes Made
Files Modified:
internal/api/oauthserver/service.go(~40 lines)validateRedirectURI()to useutilities.IsRedirectURLValid()Servermethods for config accessvalidate()methods to accept*Serverparameterinternal/api/oauthserver/service_test.go(~80 lines)TestRedirectURIValidation()to use new method signatureTestCustomURISchemes()testSetupTest()to configure test URIsReferences