Skip to content

Commit

Permalink
fix: make sure openid config uses https scheme when not localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
ymarcon committed Nov 29, 2023
1 parent 6a28ed5 commit 84acb73
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ public String getBaseURL(HttpServletRequest request) {
String baseURL;
if (Strings.isNullOrEmpty(host))
baseURL = getPublicUrl();
else if (Strings.isNullOrEmpty(getContextPath()))
baseURL = String.format("%s://%s", request.getScheme(), host);
else
baseURL = String.format("%s://%s%s", request.getScheme(), host, getContextPath());
else {
// enforce https scheme for non localhost connection
String scheme = host.startsWith("localhost:") || host.startsWith("127.0.0.1:") ? request.getScheme() : "https";
if (Strings.isNullOrEmpty(getContextPath()))
baseURL = String.format("%s://%s", scheme, host);
else
baseURL = String.format("%s://%s%s", scheme, host, getContextPath());
}
return baseURL;
}

Expand Down

0 comments on commit 84acb73

Please sign in to comment.