From 3fbc22773423ec85da07b356f7736376871e35a4 Mon Sep 17 00:00:00 2001 From: Ainur <59531286+yagudin10@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:53:12 +0200 Subject: [PATCH] CB-5559 include root uri in redirect urls (#2950) Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> --- .../registry/WebAuthProviderConfiguration.java | 2 +- .../src/io/cloudbeaver/utils/WebAppUtils.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderConfiguration.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderConfiguration.java index 32f7752fd7..322c1be6bd 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderConfiguration.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/registry/WebAuthProviderConfiguration.java @@ -80,7 +80,7 @@ public String getSignInLink() throws DBException { } private String buildRedirectUrl(String baseUrl) { - return baseUrl + "?" + CBAuthConstants.CB_REDIRECT_URL_REQUEST_PARAM + "=" + WebAppUtils.getWebApplication().getServerURL(); + return baseUrl + "?" + CBAuthConstants.CB_REDIRECT_URL_REQUEST_PARAM + "=" + WebAppUtils.getFullServerUrl(); } @Property diff --git a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebAppUtils.java b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebAppUtils.java index 607e078071..fdc44975e3 100644 --- a/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebAppUtils.java +++ b/server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/utils/WebAppUtils.java @@ -38,6 +38,8 @@ import java.nio.file.Path; import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class WebAppUtils { private static final Log log = Log.getLog(WebAppUtils.class); @@ -269,4 +271,13 @@ private static void flattenArray(Object[] array, Map result, Str } } + @NotNull + public static String getFullServerUrl() { + WebApplication application = WebAppUtils.getWebApplication(); + return Stream.of(application.getServerURL(), application.getRootURI()) + .map(WebAppUtils::removeSideSlashes) + .filter(CommonUtils::isNotEmpty) + .collect(Collectors.joining("/")); + } + }