You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(oauth2): add proper redirect URI validation to prevent invalid URIs
The OAuth2 provider app validation was too permissive, allowing invalid
redirect URIs like 'localhost:3000', '/path/only', and 'http://' to pass
validation. This caused test failures in TestOAuth2ProviderAppValidation.
Changes:
- Updated PostOAuth2ProviderAppRequest.Validate() to call validateRedirectURIs
- Updated PutOAuth2ProviderAppRequest.Validate() to call validateRedirectURIs
- Added isHostnameScheme() function to detect hostname-like schemes
- Added validation to catch common patterns like 'localhost:3000' that are
missing the http:// or https:// prefix
Fixes the failing test cases:
- URLNoHost: 'http://' now fails with scheme validation
- URLLocalhostNoScheme: 'localhost:3000' now fails with hostname detection
- URLPathOnly: '/bar/baz/qux' now fails with missing scheme validation
Co-authored-by: mattvollmer <95866673+mattvollmer@users.noreply.github.com>
returnxerrors.Errorf("redirect URI at index %d must have a scheme", i)
97
97
}
98
98
99
+
// Check for common hostname patterns used as schemes (likely missing http:// prefix)
100
+
ifisHostnameScheme(uri.Scheme) {
101
+
returnxerrors.Errorf("redirect URI at index %d: '%s' appears to be a hostname, not a valid scheme. Did you mean 'http://%s' or 'https://%s'?", i, uri.Scheme, uriStr, uriStr)
102
+
}
103
+
99
104
// Handle special URNs (RFC 6749 section 3.1.2.1)
100
105
ifuri.Scheme=="urn" {
101
106
// Allow the out-of-band redirect URI for native apps
0 commit comments