Skip to content

Commit

Permalink
CB-4500 preference to enable env variables resolving (#2522)
Browse files Browse the repository at this point in the history
* CB-4500 preference to enable env variables resolving

* CB-4500 save systemVariablesResolvingEnabled to runtime config
  • Loading branch information
alexander-skoblikov authored Apr 2, 2024
1 parent 6dfbbec commit 2936b14
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},

database: {
driver="h2_embedded_v2",
driver: "h2_embedded_v2",
url: "jdbc:h2:${workspace}/.data/cb.h2v2.dat",
initialDataConfiguration: "conf/initial-data.conf",
pool: {
Expand All @@ -65,6 +65,7 @@
grantConnectionsAccessToAnonymousTeam: false,
supportsCustomConnections: false,
showReadOnlyConnectionInfo: false,
systemVariablesResolvingEnabled: "${CLOUDBEAVER_SYSTEM_VARIABLES_RESOLVING_ENABLED:false}",

forwardProxy: false,

Expand Down
3 changes: 2 additions & 1 deletion config/sample-databases/SQLiteConfiguration/cloudbeaver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
enableSecurityManager: false,

database: {
driver="h2_embedded_v2",
driver:"h2_embedded_v2",
url: "jdbc:h2:${workspace}/.data/cb.h2v2.dat",
initialDataConfiguration: "conf/initial-data.conf",
pool: {
Expand Down Expand Up @@ -62,6 +62,7 @@
grantConnectionsAccessToAnonymousTeam: false,
supportsCustomConnections: false,
showReadOnlyConnectionInfo: false,
systemVariablesResolvingEnabled: "${CLOUDBEAVER_SYSTEM_VARIABLES_RESOLVING_ENABLED:false}",

forwardProxy: false,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class CBAppConfig extends BaseAuthWebAppConfiguration implements WebAuthC
private boolean redirectOnFederatedAuth;
private boolean anonymousAccessEnabled;
private boolean grantConnectionsAccessToAnonymousTeam;
private boolean systemVariablesResolvingEnabled;
@Deprecated
private String anonymousUserRole;
private String anonymousUserTeam;
Expand Down Expand Up @@ -85,6 +86,7 @@ public CBAppConfig() {
this.forwardProxy = false;
this.linkExternalCredentialsWithUser = true;
this.grantConnectionsAccessToAnonymousTeam = false;
this.systemVariablesResolvingEnabled = false;
}

public CBAppConfig(CBAppConfig src) {
Expand All @@ -106,6 +108,7 @@ public CBAppConfig(CBAppConfig src) {
this.forwardProxy = src.forwardProxy;
this.linkExternalCredentialsWithUser = src.linkExternalCredentialsWithUser;
this.grantConnectionsAccessToAnonymousTeam = src.grantConnectionsAccessToAnonymousTeam;
this.systemVariablesResolvingEnabled = src.systemVariablesResolvingEnabled;
}

@Override
Expand Down Expand Up @@ -296,4 +299,8 @@ public void updateDisabledDriversConfig(String[] disabledDriversConfig) {
public boolean isDriverForceEnabled(@NotNull String driverId) {
return ArrayUtils.containsIgnoreCase(getEnabledDrivers(), driverId);
}

public boolean isSystemVariablesResolvingEnabled() {
return systemVariablesResolvingEnabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -754,4 +754,9 @@ private void refreshDisabledDriversConfig() {
}
config.setDisabledDrivers(disabledDrivers.toArray(new String[0]));
}

@Override
public boolean isEnvironmentVariablesAccessible() {
return getAppConfiguration().isSystemVariablesResolvingEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,12 @@ protected Map<String, Object> collectConfigurationProperties(
appConfigProperties,
CBConstants.PARAM_CONN_GRANT_ANON_ACCESS,
appConfig.isGrantConnectionsAccessToAnonymousTeam());

copyConfigValue(
oldAppConfig,
appConfigProperties,
"systemVariablesResolvingEnabled",
appConfig.isSystemVariablesResolvingEnabled()
);
Map<String, Object> resourceQuotas = new LinkedHashMap<>();
Map<String, Object> originResourceQuotas = JSONUtils.getObject(oldAppConfig,
CBConstants.PARAM_RESOURCE_QUOTAS);
Expand Down

0 comments on commit 2936b14

Please sign in to comment.