Merge pull request #2210 from stianst/KEYCLOAK-2466
KEYCLOAK-2466 Redirection back to account/password is broken
This commit is contained in:
commit
72ded04517
3 changed files with 31 additions and 5 deletions
|
@ -21,6 +21,7 @@ import org.jboss.resteasy.spi.HttpRequest;
|
|||
import org.keycloak.AbstractOAuthClient;
|
||||
import org.keycloak.common.ClientConnection;
|
||||
import org.keycloak.OAuth2Constants;
|
||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||
import org.keycloak.models.ClientModel;
|
||||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
|
@ -113,13 +114,15 @@ public abstract class AbstractSecuredLocalService {
|
|||
throw new BadRequestException("state not specified");
|
||||
}
|
||||
|
||||
URI uri = getBaseRedirectUri();
|
||||
URI redirectUri = path != null ? uri.resolve(path) : uri;
|
||||
KeycloakUriBuilder redirect = KeycloakUriBuilder.fromUri(getBaseRedirectUri());
|
||||
if (path != null) {
|
||||
redirect.path(path);
|
||||
}
|
||||
if (referrer != null) {
|
||||
redirectUri = redirectUri.resolve("?referrer=" + referrer);
|
||||
redirect.queryParam("referrer", referrer);
|
||||
}
|
||||
|
||||
return Response.status(302).location(redirectUri).build();
|
||||
return Response.status(302).location(redirect.build()).build();
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -774,4 +774,27 @@ public class AccountTest {
|
|||
Assert.assertEquals(0, thirdPartyEntry.getProtocolMappersGranted().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loginToSpecificPage() {
|
||||
changePasswordPage.open();
|
||||
loginPage.login("test-user@localhost", "password");
|
||||
|
||||
Assert.assertTrue(changePasswordPage.isCurrent());
|
||||
|
||||
events.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void loginToSpecificPageWithReferrer() {
|
||||
driver.navigate().to(changePasswordPage.getPath() + "?referrer=account");
|
||||
System.out.println(driver.getCurrentUrl());
|
||||
|
||||
loginPage.login("test-user@localhost", "password");
|
||||
System.out.println(driver.getCurrentUrl());
|
||||
|
||||
Assert.assertTrue(changePasswordPage.isCurrent());
|
||||
|
||||
events.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class AccountPasswordPage extends AbstractAccountPage {
|
|||
}
|
||||
|
||||
public boolean isCurrent() {
|
||||
return driver.getTitle().contains("Account Management") && driver.getCurrentUrl().endsWith("/account/password");
|
||||
return driver.getTitle().contains("Account Management") && driver.getCurrentUrl().split("\\?")[0].endsWith("/account/password");
|
||||
}
|
||||
|
||||
public void open() {
|
||||
|
|
Loading…
Reference in a new issue