Skip to content

Commit 2bede00

Browse files
Merge pull request dbeaver#1094 from dbeaver/CB-2386-cb-aws-the-changed-admin-in-the-easy-config-lost-the-admin-role-after-another-user-login
CB-2386 fix multi auth in easy config
2 parents 176548b + 36e97dd commit 2bede00

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

server/bundles/io.cloudbeaver.model/src/io/cloudbeaver/model/session/WebSessionAuthProcessor.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ public List<WebAuthInfo> authenticateSession() throws DBException {
8282
@SuppressWarnings("unchecked")
8383
private List<WebAuthInfo> finishWebSessionAuthorization(SMAuthInfo authInfo) throws DBException {
8484
boolean configMode = WebAppUtils.getWebApplication().isConfigurationMode();
85-
boolean resetUserStateOnError = webSession.getUser() == null;
85+
boolean alreadyLoggedIn = webSession.getUser() != null;
86+
boolean resetUserStateOnError = !alreadyLoggedIn;
8687

8788
try {
89+
if (configMode && alreadyLoggedIn) {
90+
for (String providerId : authInfo.getAuthData().keySet()) {
91+
webSession.removeAuthInfo(providerId);
92+
}
93+
}
8894
webSession.updateSMAuthInfo(authInfo);
8995
WebUser curUser = webSession.getUser();
9096
if (curUser == null) {
@@ -117,18 +123,11 @@ private List<WebAuthInfo> finishWebSessionAuthorization(SMAuthInfo authInfo) thr
117123
}
118124

119125
SMSession authSession;
120-
if (configMode) {
121-
if (webSession.getUser() != null) {
122-
// Already logged in - remove auth token
123-
webSession.removeAuthInfo(providerId);
124-
webSession.resetAuthToken();
125-
}
126-
} else {
127-
if (authProviderExternal != null) {
128-
// We may need to associate new credentials with active user
129-
if (linkWithActiveUser) {
130-
securityController.setUserCredentials(userId, authProviderDescriptor.getId(), userCredentials);
131-
}
126+
127+
if (authProviderExternal != null && !configMode && !alreadyLoggedIn) {
128+
// We may need to associate new credentials with active user
129+
if (linkWithActiveUser) {
130+
securityController.setUserCredentials(userId, authProviderDescriptor.getId(), userCredentials);
132131
}
133132
}
134133

server/bundles/io.cloudbeaver.service.auth/src/io/cloudbeaver/service/auth/impl/WebServiceAuthImpl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public WebAuthStatus authLogin(
6666
authParameters = Map.of();
6767
}
6868
SMController securityController = webSession.getSecurityController();
69-
String currentSmSessionId = webSession.getUser() == null ? null : webSession.getUserContext().getSmSessionId();
69+
String currentSmSessionId = (webSession.getUser() == null || CBApplication.getInstance().isConfigurationMode())
70+
? null
71+
: webSession.getUserContext().getSmSessionId();
72+
7073
try {
7174
var smAuthInfo = securityController.authenticate(
7275
webSession.getSessionId(),

0 commit comments

Comments
 (0)