Fix KeycloakUriBuilder for Uris without a host name
Signed-off-by: Jan-Henrik Bruhn <github@jhbruhn.de>
This commit is contained in:
parent
6503d202ac
commit
da5fd31a5f
2 changed files with 10 additions and 2 deletions
|
@ -458,13 +458,15 @@ public class KeycloakUriBuilder {
|
|||
buffer.append(ssp);
|
||||
} else if (userInfo != null || host != null || port != -1) {
|
||||
buffer.append("//");
|
||||
if (userInfo != null)
|
||||
if (userInfo != null) {
|
||||
if (host == null || host.isEmpty()) throw new RuntimeException("empty host name, but userInfo supplied");
|
||||
replaceUserInfoParameter(paramMap, fromEncodedMap, isTemplate, userInfo, buffer).append("@");
|
||||
}
|
||||
if (host != null) {
|
||||
if ("".equals(host)) throw new RuntimeException("empty host name");
|
||||
replaceParameter(paramMap, fromEncodedMap, isTemplate, host, buffer, encodeSlash);
|
||||
}
|
||||
if (port != -1 && (preserveDefaultPort || !(("http".equals(scheme) && port == 80) || ("https".equals(scheme) && port == 443)))) {
|
||||
if (host == null || host.isEmpty()) throw new RuntimeException("empty host name, but port supplied");
|
||||
buffer.append(":").append(Integer.toString(port));
|
||||
}
|
||||
} else if (authority != null) {
|
||||
|
|
|
@ -92,4 +92,10 @@ public class KeycloakUriBuilderTest {
|
|||
Assert.assertEquals("https://user-info%E2%82%AC@localhost:8443", KeycloakUriBuilder.fromUri(
|
||||
"https://user-info€@localhost:8443", false).buildAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyHostname() {
|
||||
Assert.assertEquals("app.immich:///oauth-callback", KeycloakUriBuilder.fromUri(
|
||||
"app.immich:///oauth-callback").buildAsString());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue