From 6d6ab69c5264ee147194c2b278fed9084c9a7d19 Mon Sep 17 00:00:00 2001 From: DenisSinelnikov <142215442+DenisSinelnikov@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:31:20 +0400 Subject: [PATCH] CB-4683. Change delimiter for reverse proxy group (#2385) * CB-4683. Change delimiter for reverse proxy group * CB-4683. Refactor after review. Added new parameter team delimiter for reverse proxy identity provider, --------- Co-authored-by: DenisSinelnikov --- .../src/io/cloudbeaver/service/auth/RPConstants.java | 1 + .../src/io/cloudbeaver/service/auth/RPSessionHandler.java | 6 +++++- server/bundles/io.cloudbeaver.service.security/plugin.xml | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPConstants.java b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPConstants.java index 304be1493a..ec933d3ca2 100644 --- a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPConstants.java +++ b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPConstants.java @@ -23,4 +23,5 @@ interface RPConstants { String PARAM_FIRST_NAME = "first-name-header"; String PARAM_LAST_NAME = "last-name-header"; String PARAM_ROLE_NAME = "role-header"; + String PARAM_TEAM_DELIMITER = "team-delimiter"; } diff --git a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java index 4088b0beaa..c0508d2f92 100644 --- a/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java +++ b/server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/RPSessionHandler.java @@ -33,6 +33,7 @@ import org.jkiss.dbeaver.DBException; import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.model.auth.SMAuthInfo; +import org.jkiss.dbeaver.model.data.json.JSONUtils; import org.jkiss.dbeaver.model.security.SMAuthProviderCustomConfiguration; import org.jkiss.dbeaver.model.security.SMConstants; import org.jkiss.dbeaver.model.security.SMController; @@ -50,6 +51,7 @@ public class RPSessionHandler implements DBWSessionHandler { private static final Log log = Log.getLog(RPSessionHandler.class); + public static final String DEFAULT_TEAM_DELIMITER = "\\|"; @Override public boolean handleSessionOpen(WebSession webSession, HttpServletRequest request, HttpServletResponse response) throws DBException, IOException { @@ -95,7 +97,9 @@ public void reverseProxyAuthentication(@NotNull HttpServletRequest request, @Not String firstName = request.getHeader(resolveParam(paramConfigMap.get(RPConstants.PARAM_FIRST_NAME), RPAuthProvider.X_FIRST_NAME)); String lastName = request.getHeader(resolveParam(paramConfigMap.get(RPConstants.PARAM_LAST_NAME), RPAuthProvider.X_LAST_NAME)); String logoutUrl = Objects.requireNonNull(configuration).getParameter(RPConstants.PARAM_LOGOUT_URL); - List userTeams = teams == null ? Collections.emptyList() : List.of(teams.split("\\|")); + String teamDelimiter = JSONUtils.getString(configuration.getParameters(), + RPConstants.PARAM_TEAM_DELIMITER, "\\|"); + List userTeams = teams == null ? Collections.emptyList() : List.of(teams.split(teamDelimiter)); if (userName != null) { try { Map credentials = new HashMap<>(); diff --git a/server/bundles/io.cloudbeaver.service.security/plugin.xml b/server/bundles/io.cloudbeaver.service.security/plugin.xml index 5878dca3c7..e33370be8b 100644 --- a/server/bundles/io.cloudbeaver.service.security/plugin.xml +++ b/server/bundles/io.cloudbeaver.service.security/plugin.xml @@ -31,6 +31,7 @@ +