KEYCLOAK-8318 Workaround Elytron's double encoding of the query parameters
Co-Authored-By: mhajas <mhajas@redhat.com>
This commit is contained in:
parent
282569df23
commit
67f8622d13
4 changed files with 24 additions and 7 deletions
|
@ -19,7 +19,6 @@
|
|||
package org.keycloak.adapters.elytron;
|
||||
|
||||
import io.undertow.server.handlers.CookieImpl;
|
||||
import org.bouncycastle.asn1.cmp.Challenge;
|
||||
import org.keycloak.KeycloakSecurityContext;
|
||||
import org.keycloak.adapters.AdapterDeploymentContext;
|
||||
import org.keycloak.adapters.AdapterTokenStore;
|
||||
|
@ -31,10 +30,8 @@ import org.keycloak.adapters.spi.AuthenticationError;
|
|||
import org.keycloak.adapters.spi.LogoutError;
|
||||
import org.keycloak.enums.TokenStore;
|
||||
import org.wildfly.security.auth.server.SecurityIdentity;
|
||||
import org.wildfly.security.http.HttpAuthenticationException;
|
||||
import org.wildfly.security.http.HttpScope;
|
||||
import org.wildfly.security.http.HttpServerCookie;
|
||||
import org.wildfly.security.http.HttpServerMechanismsResponder;
|
||||
import org.wildfly.security.http.HttpServerRequest;
|
||||
import org.wildfly.security.http.HttpServerResponse;
|
||||
import org.wildfly.security.http.Scope;
|
||||
|
@ -201,9 +198,13 @@ class ElytronHttpFacade implements OIDCHttpFacade {
|
|||
if (query != null) {
|
||||
String[] parameters = query.split("&");
|
||||
for (String parameter : parameters) {
|
||||
String[] keyValue = parameter.split("=");
|
||||
String[] keyValue = parameter.split("=", 2);
|
||||
if (keyValue[0].equals(param)) {
|
||||
return keyValue[1];
|
||||
try {
|
||||
return URLDecoder.decode(keyValue[1], "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to decode request URI", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,9 +186,13 @@ class ElytronHttpFacade implements HttpFacade {
|
|||
if (query != null) {
|
||||
String[] parameters = query.split("&");
|
||||
for (String parameter : parameters) {
|
||||
String[] keyValue = parameter.split("=");
|
||||
String[] keyValue = parameter.split("=", 2);
|
||||
if (keyValue[0].equals(param)) {
|
||||
return keyValue[1];
|
||||
try {
|
||||
return URLDecoder.decode(keyValue[1], "UTF-8");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to decode request URI", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,10 @@ public class LoginForm extends Form {
|
|||
return accountFields.getUsernameLabel();
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return accountFields.getUsername();
|
||||
}
|
||||
|
||||
public String getPasswordLabel() {
|
||||
return passwordFields.getPasswordLabel();
|
||||
}
|
||||
|
|
|
@ -1409,4 +1409,12 @@ public class DemoServletsAdapterTest extends AbstractServletsAdapterTest {
|
|||
.clearDetails()
|
||||
.assertEvent();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoginHintFromClientRequest() {
|
||||
driver.navigate().to(customerPortal + "?login_hint=blah%3d");
|
||||
waitForPageToLoad();
|
||||
assertCurrentUrlStartsWithLoginUrlOf(testRealmPage);
|
||||
assertThat(testRealmLoginPage.form().getUsername(), is("blah="));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue