Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELY-2792] Spaces in query parameters are not correctly encoded for OIDC redirects #2186

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.URI;
Expand Down Expand Up @@ -204,11 +203,7 @@ public String getMethod() {

@Override
public String getURI() {
try {
return URLDecoder.decode(request.getRequestURI().toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw log.failedToDecodeRequestUri(e);
}
return request.getRequestURI().toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,25 @@ public void testSuccessfulAuthenticationWithQueryParamsWithSystemPropertyEnabled
expectedUrlAfterRedirect, CLIENT_PAGE_TEXT);
}


/**
* Reproducer for ELY-2792 - Spaces in query parameters are not correctly encoded for OIDC redirects
*/
@Test
public void testSuccessfulAuthenticationWithSpaceInQueryParamValueWithSystemPropertyEnabled() throws Exception {
String queryParams = "?myparam=a+b";
String originalUrl = getClientUrl() + queryParams;
String expectedUrlAfterRedirect = originalUrl;
performAuthentication(getOidcConfigurationInputStreamWithProviderUrl(), KeycloakConfiguration.ALICE,
KeycloakConfiguration.ALICE_PASSWORD, true, HttpStatus.SC_MOVED_TEMPORARILY, originalUrl,
expectedUrlAfterRedirect, CLIENT_PAGE_TEXT);

queryParams = "?one=a+c&two=def&three=ghi";
originalUrl = getClientUrl() + queryParams;
expectedUrlAfterRedirect = originalUrl;
performAuthentication(getOidcConfigurationInputStreamWithProviderUrl(), KeycloakConfiguration.ALICE,
KeycloakConfiguration.ALICE_PASSWORD, true, HttpStatus.SC_MOVED_TEMPORARILY, originalUrl,
expectedUrlAfterRedirect, CLIENT_PAGE_TEXT);
}

}
Loading