CB-2571 fix auth role context

This commit is contained in:
Aleksandr Skoblikov
2022-10-17 18:38:39 +02:00
parent c96ad82b4b
commit 2493676013
2 changed files with 7 additions and 3 deletions
@@ -161,7 +161,7 @@ public class WebSessionAuthProcessor {
providerConfig,
authAttrs);
if (!configMode && securityController.getUserPermissions(userId, authInfo.getAuthRole()).isEmpty()) {
if (!configMode && securityController.getUserPermissions(userId).isEmpty()) {
throw new DBWebException("Access denied (no permissions)");
}
if (!configMode && !securityController.getUserById(userId).isEnabled()) {
@@ -821,7 +821,7 @@ public class CBEmbeddedSecurityController implements SMAdminController, SMAuthen
@NotNull
@Override
public Set<String> getUserPermissions(String userId, String authRole) throws DBException {
public Set<String> getUserPermissions(String userId) throws DBException {
try (Connection dbCon = database.openConnection()) {
Set<String> permissions = new HashSet<>();
try (PreparedStatement dbStat = dbCon.prepareStatement(
@@ -849,6 +849,10 @@ public class CBEmbeddedSecurityController implements SMAdminController, SMAuthen
}
}
protected Set<String> getUserPermissions(String userId, String authRole) throws DBException {
return getUserPermissions(userId);
}
///////////////////////////////////////////
// Sessions
@@ -1547,7 +1551,7 @@ public class CBEmbeddedSecurityController implements SMAdminController, SMAuthen
} catch (SQLException e) {
throw new DBCException("Error reading token info in database", e);
}
var permissions = userId == null ? getAnonymousUserPermissions() : getUserPermissions(userId, authRole);
var permissions = userId == null ? getAnonymousUserPermissions() : getUserPermissions(userId);
return new SMAuthPermissions(userId, sessionId, permissions);
}