KEYCLOAK-12953 Ignore empty realm frontendUrl

This commit is contained in:
stianst 2020-02-14 10:52:36 +01:00 committed by Stian Thorgersen
parent 42773592ca
commit f0e3122792
2 changed files with 22 additions and 1 deletions

View file

@ -97,7 +97,7 @@ public class DefaultHostnameProvider implements HostnameProvider {
realmUri = null;
String realmFrontendUrl = session.getContext().getRealm().getAttribute("frontendUrl");
if (realmFrontendUrl != null) {
if (realmFrontendUrl != null && !realmFrontendUrl.isEmpty()) {
try {
realmUri = new URI(realmFrontendUrl);
} catch (URISyntaxException e) {

View file

@ -9,6 +9,7 @@ import org.jboss.arquillian.test.api.ArquillianResource;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.admin.client.Keycloak;
import org.keycloak.admin.client.resource.RealmResource;
import org.keycloak.broker.provider.util.SimpleHttp;
import org.keycloak.client.registration.Auth;
import org.keycloak.client.registration.ClientRegistration;
@ -99,6 +100,26 @@ public class DefaultHostnameTest extends AbstractHostnameTest {
}
}
// KEYCLOAK-12953
@Test
public void emptyRealmFrontendUrl() throws URISyntaxException {
expectedBackendUrl = AUTH_SERVER_ROOT;
oauth.clientId("direct-grant");
RealmResource realmResource = realmsResouce().realm("frontendUrl");
RealmRepresentation rep = realmResource.toRepresentation();
try {
rep.getAttributes().put("frontendUrl", "");
realmResource.update(rep);
assertWellKnown("frontendUrl", AUTH_SERVER_ROOT);
} finally {
rep.getAttributes().put("frontendUrl", realmFrontEndUrl);
realmResource.update(rep);
}
}
@Test
public void fixedAdminUrl() throws Exception {
expectedBackendUrl = AUTH_SERVER_ROOT;