spring-authorization-server
spring-authorization-server copied to clipboard
Support for private-use URI scheme redirection
trafficstars
Expected Behavior
For a redirectUri of com.example.app:/oauth2redirect/example-provider to validate.
Current Behavior
It does not validate. OAuth2AuthorizationCodeRequestAuthenticationProvider.java#L594 requires a redirectUri to have a host which is not required for private-use URI schemes.
Context
Private-Use URI Scheme Redirection allows private-use URI schemes for native apps.
Proposed Solution
Boolean isValidPrivateUseScheme = host == null && port == -1 && userInfo == null && scheme != null && scheme.contains(".")
if ((!isValidPrivateUseScheme && host == null) || host.equals("localhost")) {
// throw localhost error
}
Given rfc7595 and the currently limited URI schemes that contain a . , we could do something like the following to add more context:
Boolean isPrivateUseScheme = scheme != null && scheme.contains(".")
if (isPrivateUseScheme && (host != null || port != -1 || userInfo != null)) {
// throw invalid private use url scheme error
} else if (!isPrivateUseScheme && (host == null || host.equals("localhost"))) {
// throw localhost error
}