Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CB-4498 te secrets cleanup #2352

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
/**
* General constants
*/
public class DBWConstants {
public interface DBWConstants {

public static final String PERMISSION_ADMIN = DBAPermissionRealm.PERMISSION_ADMIN;
String PERMISSION_ADMIN = DBAPermissionRealm.PERMISSION_ADMIN;

public static final String PERMISSION_CONFIGURATION_MANAGER = RMConstants.PERMISSION_CONFIGURATION_MANAGER;
public static final String PERMISSION_PRIVATE_PROJECT_ACCESS = "private-project-access";
String PERMISSION_CONFIGURATION_MANAGER = RMConstants.PERMISSION_CONFIGURATION_MANAGER;
String PERMISSION_PRIVATE_PROJECT_ACCESS = "private-project-access";
String PERMISSION_SECRET_MANAGER = "secret-manager";

public static final String PERMISSION_EDIT_STRUCTURE = "edit-meta";
public static final String PERMISSION_EDIT_DATA = "edit-data";

public static final String STATE_ATTR_SIGN_IN_STATE = "state.signin";
String PERMISSION_EDIT_STRUCTURE = "edit-meta";
String PERMISSION_EDIT_DATA = "edit-data";

public enum SignInState {
String STATE_ATTR_SIGN_IN_STATE = "state.signin";

enum SignInState {
GLOBAL,
EMBEDDED
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.jkiss.dbeaver.model.navigator.DBNBrowseSettings;
import org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.rm.RMProjectType;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.security.*;
import org.jkiss.dbeaver.model.security.user.SMTeam;
import org.jkiss.dbeaver.model.security.user.SMUser;
Expand Down Expand Up @@ -178,6 +179,10 @@ public boolean deleteUser(@NotNull WebSession webSession, String userName) throw
}
webSession.addInfoMessage("Delete user - " + userName);
try {
var secretController = DBSSecretController.getSessionSecretControllerOrNull(webSession);
if (secretController != null) {
secretController.deleteSubjectSecrets(userName);
}
webSession.getAdminSecurityController().deleteUser(userName);
} catch (Exception e) {
throw new DBWebException("Error deleting user", e);
Expand Down Expand Up @@ -235,6 +240,10 @@ public boolean deleteTeam(@NotNull WebSession webSession, String teamId, boolean
if (Arrays.stream(userTeams).anyMatch(team -> team.getTeamId().equals(teamId))) {
throw new DBWebException("You can not delete your own team");
}
var secretController = DBSSecretController.getSessionSecretControllerOrNull(webSession);
if (secretController != null) {
secretController.deleteSubjectSecrets(teamId);
}
adminSecurityController.deleteTeam(teamId, force);
return true;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.rm.RMResource;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.security.*;
import org.jkiss.dbeaver.model.websocket.WSConstants;
import org.jkiss.dbeaver.model.websocket.event.WSProjectUpdateEvent;
Expand Down Expand Up @@ -265,6 +266,14 @@ public RMProject createProject(
@Override
public boolean deleteProject(@NotNull WebSession session, @NotNull String projectId) throws DBWebException {
try {
var project = session.getProjectById(projectId);
if (project == null) {
throw new DBException("Project not found: " + projectId);
}
if (project.isUseSecretStorage()) {
var secretController = DBSSecretController.getProjectSecretController(project);
secretController.deleteProjectSecrets(project.getId());
}
getResourceController(session).deleteProject(projectId);
session.removeSessionProject(projectId);
WebAppUtils.getWebApplication().getEventController().addEvent(
Expand Down
Loading