Skip to content

Commit

Permalink
Merge branch 'devel' into dbeaver-infra#2-renew-certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
kseniaguzeeva authored May 15, 2024
2 parents b644a70 + 6416486 commit c4abbf4
Show file tree
Hide file tree
Showing 86 changed files with 771 additions and 150 deletions.
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.model/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Model
Bundle-SymbolicName: io.cloudbeaver.model;singleton:=true
Bundle-Version: 1.0.52.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 1.0.53.qualifier
Bundle-Release-Date: 20240520
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.model</artifactId>
<version>1.0.52-SNAPSHOT</version>
<version>1.0.53-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import org.jkiss.dbeaver.model.auth.SMCredentialsProvider;
import org.jkiss.dbeaver.model.auth.SMSessionContext;
import org.jkiss.dbeaver.model.data.json.JSONUtils;
import org.jkiss.dbeaver.model.impl.app.ApplicationRegistry;
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.secret.DBSSecretController;
import org.jkiss.dbeaver.model.websocket.event.WSEventController;
import org.jkiss.dbeaver.registry.BaseApplicationImpl;
import org.jkiss.dbeaver.registry.BaseWorkspaceImpl;
import org.jkiss.dbeaver.runtime.IVariableResolver;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.dbeaver.utils.RuntimeUtils;
Expand All @@ -64,6 +64,8 @@ public abstract class BaseWebApplication extends BaseApplicationImpl implements

private static final Log log = Log.getLog(BaseWebApplication.class);

private String instanceId;

@NotNull
@Override
public DBPWorkspace createWorkspace(@NotNull DBPPlatform platform, @NotNull IWorkspace eclipseWorkspace) {
Expand Down Expand Up @@ -242,14 +244,17 @@ public Object start(IApplicationContext context) {
protected abstract void startServer() throws DBException;

@Override
public String getApplicationInstanceId() throws DBException {
try {
byte[] macAddress = RuntimeUtils.getLocalMacAddress();
String appId = ApplicationRegistry.getInstance().getApplication().getId();
return appId + "_" + CommonUtils.toHexString(macAddress) + getServerPort();
} catch (Exception e) {
throw new DBException("Error during generation instance id generation", e);
public synchronized String getApplicationInstanceId() throws DBException {
if (instanceId == null) {
try {
byte[] macAddress = RuntimeUtils.getLocalMacAddress();
// workspace id from is read from property file
instanceId = BaseWorkspaceImpl.readWorkspaceIdProperty() + "_" + CommonUtils.toHexString(macAddress);
} catch (Exception e) {
throw new DBException("Error during generation instance id generation", e);
}
}
return instanceId;
}

public String getApplicationId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public Map<String, Object> getConfigurationParameters() {
return Collections.emptyMap();
}

@NotNull
public String[] getTeams() {
return user.getUserTeams();
}
Expand Down
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.product.ce/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Community Product
Bundle-SymbolicName: io.cloudbeaver.product.ce;singleton:=true
Bundle-Version: 24.0.4.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 24.0.5.qualifier
Bundle-Release-Date: 20240520
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.product.ce/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.product.ce</artifactId>
<version>24.0.4-SNAPSHOT</version>
<version>24.0.5-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Base JDBC drivers
Bundle-SymbolicName: io.cloudbeaver.resources.drivers.base;singleton:=true
Bundle-Version: 1.0.97.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 1.0.98.qualifier
Bundle-Release-Date: 20240520
Bundle-Vendor: DBeaver Corp
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: io.cloudbeaver.resources.drivers.base
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.resources.drivers.base</artifactId>
<version>1.0.97-SNAPSHOT</version>
<version>1.0.98-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
4 changes: 2 additions & 2 deletions server/bundles/io.cloudbeaver.server/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Server
Bundle-SymbolicName: io.cloudbeaver.server;singleton:=true
Bundle-Version: 24.0.4.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 24.0.5.qualifier
Bundle-Release-Date: 20240520
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Activator: io.cloudbeaver.server.CBPlatformActivator
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.server</artifactId>
<version>24.0.4-SNAPSHOT</version>
<version>24.0.5-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ public List<String> getAvailableAuthRoles() {
return List.of();
}

public List<String> getAvailableTeamRoles() {
return List.of();
}

@Override
public WSEventController getEventController() {
return eventController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Service - Administration
Bundle-SymbolicName: io.cloudbeaver.service.admin;singleton:=true
Bundle-Version: 1.0.96.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 1.0.97.qualifier
Bundle-Release-Date: 20240520
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.service.admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.service.admin</artifactId>
<version>1.0.96-SNAPSHOT</version>
<version>1.0.97-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ type AdminConnectionGrantInfo {
subjectType: AdminSubjectType!
}

type AdminUserTeamGrantInfo @since(version: "24.0.5"){
userId: ID!
teamRole: String
}

type AdminObjectPermissions {
objectId: ID!
permissions: [String!]!
Expand Down Expand Up @@ -53,6 +58,7 @@ type AdminTeamInfo {
metaParameters: Object!

grantedUsers: [ID!]!
grantedUsersInfo: [AdminUserTeamGrantInfo!]! @since(version: "24.0.5")
grantedConnections: [AdminConnectionGrantInfo!]!

teamPermissions: [ID!]!
Expand Down Expand Up @@ -128,6 +134,7 @@ extend type Query {
listTeams(teamId: ID): [AdminTeamInfo!]!
listPermissions: [AdminPermissionInfo!]!
listAuthRoles: [String!]!
listTeamRoles: [String!]!
listTeamMetaParameters: [ObjectPropertyInfo!]!

createUser(userId: ID!, enabled: Boolean!, authRole: String): AdminUserInfo!
Expand All @@ -150,6 +157,8 @@ extend type Query {

setUserAuthRole(userId: ID!, authRole: String): Boolean

setUserTeamRole(userId: ID!, teamId: ID!, teamRole: String): Boolean @since(version: "24.0.5")

#### Connection management

# All connection configurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.security.SMDataSourceGrant;
import org.jkiss.dbeaver.model.security.SMObjectType;
import org.jkiss.dbeaver.model.security.SMTeamMemberInfo;
import org.jkiss.dbeaver.model.security.user.SMTeam;

import java.util.ArrayList;
Expand Down Expand Up @@ -88,4 +89,8 @@ public String[] getGrantedUsers() throws DBException {
return session.getAdminSecurityController().getTeamMembers(getTeamId());
}

@Property
public List<SMTeamMemberInfo> getGrantedUsersInfo() throws DBException {
return session.getAdminSecurityController().getTeamMembersInfo(getTeamId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ AdminUserInfo createUser(
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
List<String> listAuthRoles();

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
List<String> listTeamRoles();

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
boolean deleteUser(@NotNull WebSession webSession, String userName) throws DBWebException;

Expand Down Expand Up @@ -202,4 +205,10 @@ WebPropertyInfo saveUserMetaParameter(WebSession webSession, String id, String d
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean setUserAuthRole(WebSession webSession, String userId, String authRole) throws DBWebException;

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean setUserTeamRole(
@NotNull WebSession webSession, @NotNull String userId,
@NotNull String teamId, @Nullable String teamRole
) throws DBWebException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
env -> getService(env).listPermissions(getWebSession(env)))
.dataFetcher("listAuthRoles",
env -> getService(env).listAuthRoles())
.dataFetcher("listTeamRoles",
env -> getService(env).listTeamRoles())
.dataFetcher("listTeamMetaParameters",
env -> getService(env).listTeamMetaParameters(getWebSession(env)))
.dataFetcher("createUser",
Expand Down Expand Up @@ -106,6 +108,14 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
env -> getService(env).enableUser(getWebSession(env), env.getArgument("userId"), env.getArgument("enabled")))
.dataFetcher("setUserAuthRole",
env -> getService(env).setUserAuthRole(getWebSession(env), env.getArgument("userId"), env.getArgument("authRole")))
.dataFetcher("setUserTeamRole",
env -> getService(env).setUserTeamRole(
getWebSession(env),
env.getArgument("userId"),
env.getArgument("teamId"),
env.getArgument("teamRole")
)
)
.dataFetcher("searchConnections", env -> getService(env).searchConnections(getWebSession(env), env.getArgument("hostNames")))
.dataFetcher("getConnectionSubjectAccess",
env -> getService(env).getConnectionSubjectAccess(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public List<String> listAuthRoles() {
return CBApplication.getInstance().getAvailableAuthRoles();
}

@Override
public List<String> listTeamRoles() {
return CBApplication.getInstance().getAvailableTeamRoles();
}

@Override
public boolean deleteUser(@NotNull WebSession webSession, String userName) throws DBWebException {
if (CommonUtils.equalObjects(userName, webSession.getUser().getUserId())) {
Expand Down Expand Up @@ -392,6 +397,21 @@ public Boolean setUserAuthRole(WebSession webSession, String userId, String auth
}
}

@Override
public Boolean setUserTeamRole(
@NotNull WebSession webSession,
@NotNull String userId,
@NotNull String teamId,
@Nullable String teamRole
) throws DBWebException {
try {
webSession.getAdminSecurityController().setUserTeamRole(userId, teamId, teamRole);
return true;
} catch (Exception e) {
throw new DBWebException("Error updating user auth role", e);
}
}

////////////////////////////////////////////////////////////////////
// Connection management

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Bundle-ManifestVersion: 2
Bundle-Vendor: DBeaver Corp
Bundle-Name: Cloudbeaver Web Service - Authentication
Bundle-SymbolicName: io.cloudbeaver.service.auth;singleton:=true
Bundle-Version: 1.0.96.qualifier
Bundle-Release-Date: 20240506
Bundle-Version: 1.0.97.qualifier
Bundle-Release-Date: 20240520
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
Expand Down
2 changes: 1 addition & 1 deletion server/bundles/io.cloudbeaver.service.auth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<relativePath>../</relativePath>
</parent>
<artifactId>io.cloudbeaver.service.auth</artifactId>
<version>1.0.96-SNAPSHOT</version>
<version>1.0.97-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ type UserInfo {
metaParameters: Object!
# User configuration parameters
configurationParameters: Object!
# User teams
teams: [UserTeamInfo!]!
}

type UserTeamInfo {
teamId: String!
teamName: String!
teamRole: String
}

extend type Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import io.cloudbeaver.DBWebException;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.model.user.WebUser;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.meta.Property;
Expand Down Expand Up @@ -88,4 +89,19 @@ public Map<String, Object> getConfigurationParameters() throws DBWebException {
return session.getUserContext().getPreferenceStore().getCustomUserParameters();
}

@NotNull
@Property
public List<WebUserTeamInfo> getTeams() throws DBWebException {
if (session.getUserContext().isNonAnonymousUserAuthorizedInSM()) {
try {
return Arrays.stream(session.getSecurityController().getCurrentUserTeams())
.map(WebUserTeamInfo::new)
.toList();
} catch (DBException e) {
throw new DBWebException("Error reading user's teams", e);
}
} else {
return List.of();
}
}
}
Loading

0 comments on commit c4abbf4

Please sign in to comment.