8942 - port in location header is -1 when doing SAML global logout

This commit is contained in:
Hisanobu Okuda 2021-12-01 12:26:12 +09:00 committed by Hynek Mlnařík
parent c474e770fe
commit 24e7ab6748

View file

@ -173,7 +173,13 @@ class KeycloakHttpServerAuthenticationMechanism implements HttpServerAuthenticat
String path = uri.getPath();
String relativePath = exchange.getRequest().getRelativePath();
String contextPath = path.substring(0, path.indexOf(relativePath));
String loc = exchange.getURI().getScheme() + "://" + exchange.getURI().getHost() + ":" + exchange.getURI().getPort() + contextPath + location;
String loc;
int port = uri.getPort();
if (port == -1) {
loc = uri.getScheme() + "://" + uri.getHost() + contextPath + location;
} else {
loc = uri.getScheme() + "://" + uri.getHost() + ":" + port + contextPath + location;
}
exchange.getResponse().setHeader("Location", loc);
}
exchange.getResponse().setStatus(HttpServletResponse.SC_FOUND);