diff --git a/CHANGELOG.md b/CHANGELOG.md index 909046f6..fc90854d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ### 0.3.2-SNAPSHOT (TBD) +#### Bugfixes +Fix the server url when `useLoopbackIpAddress` OAuth2 option is used. ---------------------- diff --git a/jpro-auth/core/src/main/java/one/jpro/platform/auth/core/oauth2/OAuth2AuthenticationProvider.java b/jpro-auth/core/src/main/java/one/jpro/platform/auth/core/oauth2/OAuth2AuthenticationProvider.java index b5630352..33da7e36 100755 --- a/jpro-auth/core/src/main/java/one/jpro/platform/auth/core/oauth2/OAuth2AuthenticationProvider.java +++ b/jpro-auth/core/src/main/java/one/jpro/platform/auth/core/oauth2/OAuth2AuthenticationProvider.java @@ -669,15 +669,16 @@ private String normalizeUri(String uri) { if (httpServer != null && redirectUri != null && redirectUri.charAt(0) == '/') { final int port = httpServer.getServerPort(); String server = httpServer.getServerHost(); + boolean isLocalAddress = false; final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress(); - if (options.isUseLoopbackIpAddress()) { + if (options.isUseLoopbackIpAddress() && server.equals("localhost")) { server = loopbackAddress; + isLocalAddress = true; } - final boolean localAddress = server.equals("localhost") || server.equals(loopbackAddress); if (port > 0) { server += ":" + port; } - final String serverUrl = localAddress ? "http://" + server : "https://" + server; + final String serverUrl = isLocalAddress ? "http://" + server : "https://" + server; redirectUri = serverUrl + redirectUri; } return redirectUri;