Skip to content

Commit

Permalink
Merge branch 'devel' into dbeaver/dbeaver-vscode#45-server-features
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud authored Nov 26, 2024
2 parents 3961244 + 979cecf commit e8d33cc
Show file tree
Hide file tree
Showing 118 changed files with 1,436 additions and 166 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ You can see a live demo of CloudBeaver here: https://demo.cloudbeaver.io

## Changelog

### 24.2.5. 2024-11-18
- Updated user storage mechanism: New user logins are now stored in lowercase to prevent duplicate entries (e.g., "ADMIN" and "admin"). Note: This update does not affect previously created user logins;
- A new setting in Global Preferences was added to restrict data import for non-admin users.

### 24.2.4. 2024-11-04
- General:
- Data export: Added the ability to export JSON values as embedded JSON;
Expand Down
3 changes: 1 addition & 2 deletions deploy/docker/base-java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ RUN set -eux; \
tzdata \
# locales ensures proper character encoding and locale-specific behaviors using en_US.UTF-8
locales \
nano \
; \
nano && \
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen; \
locale-gen en_US.UTF-8; \
rm -rf /var/lib/apt/lists/*
Expand Down
20 changes: 16 additions & 4 deletions deploy/docker/cloudbeaver-ce/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@ FROM dbeaver/base-java

MAINTAINER DBeaver Corp, [email protected]

RUN apt-get update; \
apt-get upgrade -y;

ENV DBEAVER_GID=8978
ENV DBEAVER_UID=8978

RUN apt-get update && \
apt-get upgrade -y

RUN groupadd -g $DBEAVER_GID dbeaver && \
useradd -g $DBEAVER_GID -M -u $DBEAVER_UID -s /bin/bash dbeaver

COPY cloudbeaver /opt/cloudbeaver
COPY scripts/launch-product.sh /opt/cloudbeaver/launch-product.sh

RUN chown -R $DBEAVER_UID:$DBEAVER_GID /opt/cloudbeaver

EXPOSE 8978
RUN find /opt/cloudbeaver -type d -exec chmod 775 {} \;
WORKDIR /opt/cloudbeaver/
ENTRYPOINT ["./run-server.sh"]

RUN chmod +x "run-server.sh" "/opt/cloudbeaver/launch-product.sh"

ENTRYPOINT ["./launch-product.sh"]
11 changes: 11 additions & 0 deletions deploy/scripts/launch-product.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# This script is needed to change ownership and run the application as user dbeaver during the upgrade from version 24.2.0

# Change ownership of the WORKDIR to the dbeaver user and group
# Variables DBEAVER_<UID|GID> are defined in the Dockerfile and exported to the runtime environment
# PWD equals WORKDIR value from product Dockerfile
chown -R $DBEAVER_UID:$DBEAVER_GID $PWD

# Execute run-server.sh as the dbeaver user with the JAVA_HOME and PATH environment variables
exec su dbeaver -c "JAVA_HOME=$JAVA_HOME PATH=$PATH ./run-server.sh"
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.66.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 1.0.67.qualifier
Bundle-Release-Date: 20241223
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.66-SNAPSHOT</version>
<version>1.0.67-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ public String moveResource(
if (Files.exists(newTargetPath)) {
throw new DBException("Resource with name %s already exists".formatted(newTargetPath.getFileName()));
}
if (!Files.exists(newTargetPath.getParent())) {
throw new DBException("Resource %s doesn't exists".formatted(newTargetPath.getParent().getFileName()));
}
try {
Files.move(oldTargetPath, newTargetPath);
} catch (IOException e) {
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.3.0.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 24.3.1.qualifier
Bundle-Release-Date: 20241223
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.3.0-SNAPSHOT</version>
<version>24.3.1-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.111.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 1.0.112.qualifier
Bundle-Release-Date: 20241223
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.111-SNAPSHOT</version>
<version>1.0.112-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.3.0.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 24.3.1.qualifier
Bundle-Release-Date: 20241223
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Bundle-Activator: io.cloudbeaver.server.CBPlatformActivator
Expand Down
8 changes: 8 additions & 0 deletions server/bundles/io.cloudbeaver.server/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,12 @@
</eventHandler>
</extension>

<extension point="org.jkiss.dbeaver.settings">
<propertyGroup id="log" label="Logger">
<property id="log.api.graphql.debug" label="Enable detailed logging"
type="boolean" scopes="global"
description="Enable detailed logging of GraphQL queries in the server log, including all provided variables"/>
</propertyGroup>
</extension>

</plugin>
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.3.0-SNAPSHOT</version>
<version>24.3.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ type ProductInfo {
licenseInfo: String

latestVersionInfo: String
productPurchaseURL: String
}

type ServerConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,10 @@ public String getLatestVersionInfo() {
return CommonUtils.notEmpty(product.getProperty("versionUpdateURL"));
}

@Property
public String getProductPurchaseURL() {
IProduct product = Platform.getProduct();
return CommonUtils.notEmpty(product.getProperty("productPurchaseURL"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public synchronized void finishConfiguration(
}

if (isConfigurationMode()) {
finishSecurityServiceConfiguration(adminName, adminPassword, authInfoList);
finishSecurityServiceConfiguration(adminName.toLowerCase(), adminPassword, authInfoList);
}

// Save runtime configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
import java.io.Reader;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.CompletableFuture;

public class GraphQLEndpoint extends HttpServlet {
Expand All @@ -68,7 +65,6 @@ public class GraphQLEndpoint extends HttpServlet {
private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";

private static final String CORE_SCHEMA_FILE_NAME = "schema/schema.graphqls";

private final GraphQL graphQL;

private static final Gson gson = new GsonBuilder()
Expand Down Expand Up @@ -253,10 +249,13 @@ private void executeQuery(HttpServletRequest request, HttpServletResponse respon
// apiCall += " (" + variables + ")";
// }
// }
String sessionId = GraphQLLoggerUtil.getSessionId(request);
String userId = GraphQLLoggerUtil.getUserId(request);
String loggerMessage = GraphQLLoggerUtil.buildLoggerMessage(sessionId, userId, variables);
if (apiCall != null) {
log.debug("API > " + apiCall);
log.debug("API > " + apiCall + loggerMessage);
} else if (DEBUG) {
log.debug("API > " + query);
log.debug("API > " + query + loggerMessage);
}
}
ExecutionInput executionInput = contextBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2024 DBeaver Corp and others
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudbeaver.server.graphql;

import io.cloudbeaver.model.app.BaseWebApplication;
import io.cloudbeaver.model.session.WebSession;
import io.cloudbeaver.server.CBApplication;
import io.cloudbeaver.server.CBPlatform;
import jakarta.servlet.http.HttpServletRequest;
import org.jkiss.code.Nullable;
import org.jkiss.utils.CommonUtils;

import java.util.Map;
import java.util.Set;

public class GraphQLLoggerUtil {

public static final String LOG_API_GRAPHQL_DEBUG_PARAMETER = "log.api.graphql.debug";
private static final Set<String> PROHIBITED_VARIABLES =
Set.of("password", "config", "parameters", "settings", "licenseText", "credentials", "username");

public static String getUserId(HttpServletRequest request) {
WebSession session = getWebSession(request);
if (session == null) {
return null;
}
String userId = session.getUserContext().getUserId();
if (userId == null && session.getUserContext().isAuthorizedInSecurityManager()) {
return "anonymous";
}
return userId;
}

public static String getSessionId(HttpServletRequest request) {
WebSession session = getWebSession(request);
if (session == null) {
return null;
}
return session.getUserContext().getSmSessionId();
}

@Nullable
private static WebSession getWebSession(HttpServletRequest request) {
if (request.getSession() == null) {
return null;
}

if (BaseWebApplication.getInstance() instanceof CBApplication<?> cbApp) {
return (WebSession)cbApp.getSessionManager()
.getSession(request.getSession().getId());
} else {
return null;
}
}

public static String buildLoggerMessage(String sessionId, String userId, Map<String, Object> variables) {
StringBuilder loggerMessage = new StringBuilder(" [user: ").append(userId)
.append(", sessionId: ").append(sessionId).append("]");

if (CBPlatform.getInstance().getPreferenceStore().getBoolean(LOG_API_GRAPHQL_DEBUG_PARAMETER)
&& variables != null
) {
loggerMessage.append(" [variables] ");
String parsedVariables = parseVarialbes(variables);
if (CommonUtils.isNotEmpty(parsedVariables)) {
loggerMessage.append(parseVarialbes(variables));
}
}
return loggerMessage.toString();
}

private static String parseVarialbes(Map<String, Object> map) {
StringBuilder result = new StringBuilder();

for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();

boolean isProhibited = PROHIBITED_VARIABLES.stream()
.anyMatch(prohibitedKey -> key.toLowerCase().contains(prohibitedKey.toLowerCase()));

if (isProhibited) {
result.append(key).append(": ").append("******** ");
continue;
}

if (value instanceof Map) {
result.append(parseVarialbes((Map<String, Object>) value));
} else {
result.append(key).append(": ").append(value).append(" ");
}
}
return result.toString().trim();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public String[] getFeatures() {
if (node instanceof DBNDatabaseNode) {
boolean canEditDatasources = hasNodePermission(RMProjectPermission.DATA_SOURCES_EDIT);
DBSObject object = ((DBNDatabaseNode) node).getObject();
if (object != null && canEditDatasources) {
if (object != null && canEditDatasources && !DBUtils.isReadOnly(object)) {
DBEObjectMaker objectManager = DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(
object.getClass(), DBEObjectMaker.class);
if (objectManager != null && objectManager.canDeleteObject(object)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void run(DBRProgressMonitor monitor) throws InvocationTargetException, In
public Boolean isAutoCommit() throws DBWebException {
DBCExecutionContext context = processor.getExecutionContext();
DBCTransactionManager txnManager = DBUtils.getTransactionManager(context);
if (txnManager == null) {
if (txnManager == null || !txnManager.isSupportsTransactions()) {
return null;
}
try {
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.110.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 1.0.111.qualifier
Bundle-Release-Date: 20241223
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.110-SNAPSHOT</version>
<version>1.0.111-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
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.110.qualifier
Bundle-Release-Date: 20241202
Bundle-Version: 1.0.111.qualifier
Bundle-Release-Date: 20241223
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.110-SNAPSHOT</version>
<version>1.0.111-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

</project>
Loading

0 comments on commit e8d33cc

Please sign in to comment.