Skip to content

Commit

Permalink
Fix the server url when useLoopbackIpAddress OAuth2 option is used
Browse files Browse the repository at this point in the history
  • Loading branch information
besidev committed May 14, 2024
1 parent 103a461 commit 1e7c27e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
### 0.3.2-SNAPSHOT (TBD)

#### Bugfixes
Fix the server url when `useLoopbackIpAddress` OAuth2 option is used.

----------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1e7c27e

Please sign in to comment.