Skip to content

Commit

Permalink
Merge branch 'devel' of https://github.com/dbeaver/cloudbeaver into d…
Browse files Browse the repository at this point in the history
…beaver/pro#2403-gs-auth-model
  • Loading branch information
serge-rider committed Feb 1, 2024
2 parents db06622 + 8585af7 commit 6a653c5
Show file tree
Hide file tree
Showing 362 changed files with 4,349 additions and 2,080 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,7 @@ public synchronized void finishConfiguration(
}
}

String sessionId = null;
if (credentialsProvider != null && credentialsProvider.getActiveUserCredentials() != null) {
sessionId = credentialsProvider.getActiveUserCredentials().getSmSessionId();
}
eventController.addEvent(new WSServerConfigurationChangedEvent(sessionId, null));
sendConfigChangedEvent(credentialsProvider);
eventController.setForceSkipEvents(isConfigurationMode());
}

Expand Down Expand Up @@ -992,11 +988,10 @@ protected void saveRuntimeConfig(
sessionExpireTime,
appConfig);
validateConfiguration(configurationProperties);
writeRuntimeConfig(configurationProperties);
writeRuntimeConfig(getRuntimeAppConfigFile(), configurationProperties);
}

private void writeRuntimeConfig(Map<String, Object> configurationProperties) throws DBException {
File runtimeConfigFile = getRuntimeAppConfigFile();
private void writeRuntimeConfig(File runtimeConfigFile, Map<String, Object> configurationProperties) throws DBException {
if (runtimeConfigFile.exists()) {
ContentUtils.makeFileBackup(runtimeConfigFile.toPath());
}
Expand Down Expand Up @@ -1024,33 +1019,7 @@ protected Map<String, Object> collectConfigurationProperties(
var serverConfigProperties = new LinkedHashMap<String, Object>();
var originServerConfig = getServerConfigProps(this.originalConfigurationProperties); // get server properties from original configuration file
rootConfig.put("server", serverConfigProperties);
if (!CommonUtils.isEmpty(newServerName)) {
copyConfigValue(originServerConfig,
serverConfigProperties,
CBConstants.PARAM_SERVER_NAME,
newServerName);
}
if (!CommonUtils.isEmpty(newServerURL)) {
copyConfigValue(
originServerConfig, serverConfigProperties, CBConstants.PARAM_SERVER_URL, newServerURL);
}
if (sessionExpireTime > 0) {
copyConfigValue(
originServerConfig,
serverConfigProperties,
CBConstants.PARAM_SESSION_EXPIRE_PERIOD,
sessionExpireTime);
}
var databaseConfigProperties = new LinkedHashMap<String, Object>();
Map<String, Object> oldRuntimeDBConfig = JSONUtils.getObject(originServerConfig,
CBConstants.PARAM_DB_CONFIGURATION);
if (!CommonUtils.isEmpty(databaseConfiguration) && !isDistributed()) {
for (Map.Entry<String, Object> mp : databaseConfiguration.entrySet()) {
copyConfigValue(oldRuntimeDBConfig, databaseConfigProperties, mp.getKey(), mp.getValue());
}
serverConfigProperties.put(CBConstants.PARAM_DB_CONFIGURATION, databaseConfigProperties);
}
savePasswordPolicyConfig(originServerConfig, serverConfigProperties);
collectServerConfigProperties(newServerName, newServerURL, sessionExpireTime, originServerConfig, serverConfigProperties);
}
{
var appConfigProperties = new LinkedHashMap<String, Object>();
Expand Down Expand Up @@ -1160,7 +1129,43 @@ protected Map<String, Object> collectConfigurationProperties(
return rootConfig;
}

private void savePasswordPolicyConfig(Map<String, Object> originServerConfig, LinkedHashMap<String, Object> serverConfigProperties) {
protected void collectServerConfigProperties(
String newServerName,
String newServerURL,
long sessionExpireTime,
Map<String, Object> originServerConfig,
Map<String, Object> serverConfigProperties
) {
if (!CommonUtils.isEmpty(newServerName)) {
copyConfigValue(originServerConfig,
serverConfigProperties,
CBConstants.PARAM_SERVER_NAME,
newServerName);
}
if (!CommonUtils.isEmpty(newServerURL)) {
copyConfigValue(
originServerConfig, serverConfigProperties, CBConstants.PARAM_SERVER_URL, newServerURL);
}
if (sessionExpireTime > 0) {
copyConfigValue(
originServerConfig,
serverConfigProperties,
CBConstants.PARAM_SESSION_EXPIRE_PERIOD,
sessionExpireTime);
}
var databaseConfigProperties = new LinkedHashMap<String, Object>();
Map<String, Object> oldRuntimeDBConfig = JSONUtils.getObject(originServerConfig,
CBConstants.PARAM_DB_CONFIGURATION);
if (!CommonUtils.isEmpty(databaseConfiguration) && !isDistributed()) {
for (Map.Entry<String, Object> mp : databaseConfiguration.entrySet()) {
copyConfigValue(oldRuntimeDBConfig, databaseConfigProperties, mp.getKey(), mp.getValue());
}
serverConfigProperties.put(CBConstants.PARAM_DB_CONFIGURATION, databaseConfigProperties);
}
savePasswordPolicyConfig(originServerConfig, serverConfigProperties);
}

private void savePasswordPolicyConfig(Map<String, Object> originServerConfig, Map<String, Object> serverConfigProperties) {
// save password policy configuration
var passwordPolicyProperties = new LinkedHashMap<String, Object>();

Expand Down Expand Up @@ -1297,4 +1302,19 @@ public Class<? extends DBPPlatform> getPlatformClass() {
public Class<? extends DBPPlatformUI> getPlatformUIClass() {
return CBPlatformUI.class;
}

public void saveProductConfiguration(SMCredentialsProvider credentialsProvider, Map<String, Object> productConfiguration) throws DBException {
Map<String, Object> mergedConfig = WebAppUtils.mergeConfigurations(this.productConfiguration, productConfiguration);
writeRuntimeConfig(getRuntimeProductConfigFilePath().toFile(), mergedConfig);
this.productConfiguration.putAll(mergedConfig);
sendConfigChangedEvent(credentialsProvider);
}

protected void sendConfigChangedEvent(SMCredentialsProvider credentialsProvider) {
String sessionId = null;
if (credentialsProvider != null && credentialsProvider.getActiveUserCredentials() != null) {
sessionId = credentialsProvider.getActiveUserCredentials().getSmSessionId();
}
eventController.addEvent(new WSServerConfigurationChangedEvent(sessionId, null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,8 @@ extend type Query {
setDefaultNavigatorSettings( settings: NavigatorSettingsInput!): Boolean!

}

extend type Mutation {
# Updates product configuration
adminUpdateProductConfiguration(configuration: Object!): Boolean! @since(version: "23.3.4")
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ WebAuthProviderConfiguration saveAuthProviderConfiguration(
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
boolean setDefaultNavigatorSettings(WebSession webSession, DBNBrowseSettings settings) throws DBWebException;

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
boolean updateProductConfiguration(WebSession webSession, Map<String, Object> productConfiguration) throws DBWebException;

////////////////////////////////////////////////////////////////////
// Permissions

Expand Down Expand Up @@ -179,6 +182,7 @@ boolean setSubjectConnectionAccess(@NotNull WebSession webSession, @NotNull Stri
DBWebException;

////////////////////////////////////////////////////////////////////

// User meta parameters

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Expand All @@ -187,11 +191,11 @@ WebPropertyInfo saveUserMetaParameter(WebSession webSession, String id, String d

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean deleteUserMetaParameter(WebSession webSession, String id) throws DBWebException;

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean setUserMetaParameterValues(WebSession webSession, String userId, Map<String, String> parameters) throws DBWebException;
@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean setTeamMetaParameterValues(WebSession webSession, String teamId, Map<String, String> parameters) throws DBWebException;

@WebAction(requirePermissions = DBWConstants.PERMISSION_ADMIN)
Boolean enableUser(WebSession webSession, String userId, Boolean enabled) throws DBWebException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ public void bindWiring(DBWBindingContext model) throws DBWebException {
.dataFetcher("setDefaultNavigatorSettings",
env -> getService(env).setDefaultNavigatorSettings(getWebSession(env), WebServiceUtils.parseNavigatorSettings(env.getArgument("settings"))))
;
model.getMutationType()
.dataFetcher("adminUpdateProductConfiguration",
env -> getService(env).updateProductConfiguration(getWebSession(env), env.getArgument("configuration")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,17 @@ public boolean setDefaultNavigatorSettings(WebSession webSession, DBNBrowseSetti
return true;
}


@Override
public boolean updateProductConfiguration(WebSession webSession, Map<String, Object> productConfiguration) throws DBWebException {
try {
CBApplication.getInstance().saveProductConfiguration(webSession, productConfiguration);
return true;
} catch (DBException e) {
throw new DBWebException("Error updating product configuration", e);
}
}

////////////////////////////////////////////////////////////////////
// Access management

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { NotificationService } from '@cloudbeaver/core-events';
import { Executor, IExecutor } from '@cloudbeaver/core-executor';
import { EAdminPermission, PermissionsService, ServerConfigResource, SessionPermissionsResource } from '@cloudbeaver/core-root';
import { RouterState, ScreenService } from '@cloudbeaver/core-routing';
import { LocalStorageSaveService } from '@cloudbeaver/core-settings';
import { SettingsService } from '@cloudbeaver/core-settings';
import { GlobalConstants } from '@cloudbeaver/core-utils';

import { AdministrationItemService } from '../AdministrationItem/AdministrationItemService';
Expand Down Expand Up @@ -69,7 +69,7 @@ export class AdministrationScreenService {
private readonly permissionsService: PermissionsService,
private readonly screenService: ScreenService,
private readonly administrationItemService: AdministrationItemService,
private readonly autoSaveService: LocalStorageSaveService,
private readonly settingsService: SettingsService,
private readonly serverConfigResource: ServerConfigResource,
private readonly notificationService: NotificationService,
) {
Expand All @@ -84,8 +84,8 @@ export class AdministrationScreenService {
activeScreen: computed,
});

this.autoSaveService.withAutoSave(ADMINISTRATION_ITEMS_STATE, this.itemState, () => new Map());
this.autoSaveService.withAutoSave(ADMINISTRATION_INFO, this.info, getDefaultAdministrationScreenInfo);
this.settingsService.registerSettings(ADMINISTRATION_ITEMS_STATE, this.itemState, () => new Map());
this.settingsService.registerSettings(ADMINISTRATION_INFO, this.info, getDefaultAdministrationScreenInfo);
this.permissionsResource.onDataUpdate.addPostHandler(() => {
this.checkPermissions(this.screenService.routerService.state);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
*/
import { injectable } from '@cloudbeaver/core-di';
import { PluginManagerService, PluginSettings } from '@cloudbeaver/core-plugin';
import { schema } from '@cloudbeaver/core-utils';

const defaultSettings = {
baseFeatures: [] as string[],
};
const settingsSchema = schema.object({
baseFeatures: schema.array(schema.string()).default([]),
});

export type AdministrationSettings = typeof defaultSettings;
export type AdministrationSettings = schema.infer<typeof settingsSchema>;

@injectable()
export class AdministrationSettingsService {
readonly settings: PluginSettings<AdministrationSettings>;
readonly settings: PluginSettings<typeof settingsSchema>;

constructor(private readonly pluginManagerService: PluginManagerService) {
this.settings = this.pluginManagerService.createSettings('administration', 'core', defaultSettings);
this.settings = this.pluginManagerService.createSettings('administration', 'core', settingsSchema);
}

isBase(feature: string): boolean {
Expand Down
40 changes: 20 additions & 20 deletions webapp/packages/core-administration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
},
"references": [
{
"path": "../core-browser/tsconfig.json"
},
{
"path": "../core-data-context/tsconfig.json"
},
Expand All @@ -16,58 +19,55 @@
"path": "../core-events/tsconfig.json"
},
{
"path": "../core-executor/tsconfig.json"
},
{
"path": "../core-localization/tsconfig.json"
"path": "../core-events/tsconfig.json"
},
{
"path": "../core-plugin/tsconfig.json"
"path": "../core-executor/tsconfig.json"
},
{
"path": "../core-resource/tsconfig.json"
"path": "../core-localization/tsconfig.json"
},
{
"path": "../core-root/tsconfig.json"
"path": "../core-localization/tsconfig.json"
},
{
"path": "../core-routing/tsconfig.json"
"path": "../core-plugin/tsconfig.json"
},
{
"path": "../core-sdk/tsconfig.json"
"path": "../core-plugin/tsconfig.json"
},
{
"path": "../core-settings/tsconfig.json"
"path": "../core-product/tsconfig.json"
},
{
"path": "../core-theming/tsconfig.json"
"path": "../core-resource/tsconfig.json"
},
{
"path": "../core-utils/tsconfig.json"
"path": "../core-root/tsconfig.json"
},
{
"path": "../core-browser/tsconfig.json"
"path": "../core-root/tsconfig.json"
},
{
"path": "../core-events/tsconfig.json"
"path": "../core-routing/tsconfig.json"
},
{
"path": "../core-localization/tsconfig.json"
"path": "../core-sdk/tsconfig.json"
},
{
"path": "../core-plugin/tsconfig.json"
"path": "../core-sdk/tsconfig.json"
},
{
"path": "../core-product/tsconfig.json"
"path": "../core-settings/tsconfig.json"
},
{
"path": "../core-root/tsconfig.json"
"path": "../core-settings/tsconfig.json"
},
{
"path": "../core-sdk/tsconfig.json"
"path": "../core-theming/tsconfig.json"
},
{
"path": "../core-settings/tsconfig.json"
"path": "../core-utils/tsconfig.json"
},
{
"path": "../tests-runner/tsconfig.json"
Expand Down
5 changes: 2 additions & 3 deletions webapp/packages/core-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@
"@cloudbeaver/core-executor": "~0.1.0",
"@cloudbeaver/core-localization": "~0.1.0",
"@cloudbeaver/core-notifications": "~0.1.0",
"@cloudbeaver/core-plugin": "~0.1.0",
"@cloudbeaver/core-projects": "~0.1.0",
"@cloudbeaver/core-resource": "~0.1.0",
"@cloudbeaver/core-root": "~0.1.0",
"@cloudbeaver/core-routing": "~0.1.0",
"@cloudbeaver/core-theming": "~0.1.0",
"@cloudbeaver/core-ui": "~0.1.0",
"@cloudbeaver/core-utils": "~0.1.0",
"@cloudbeaver/core-version": "~0.1.0",
"mobx-react-lite": "^4.0.5",
"react": "^18.2.0",
"@cloudbeaver/core-utils": "~0.1.0"
"react": "^18.2.0"
},
"peerDependencies": {},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/core-app/src/AppScreen/Main.m.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.space {
composes: theme-typography--body2 theme-background-primary from global;
composes: theme-background-surface theme-text-on-surface from global;
display: flex;
flex-direction: row;
flex: 1;
Expand Down
7 changes: 1 addition & 6 deletions webapp/packages/core-app/src/AppScreen/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ export const Main = observer(function Main() {
return (
<Loader className={s(styles, { loader: true })} suspense>
<main className={s(styles, { space: true })}>
<Split
{...splitMainState}
sticky={30}
mode={leftBarDisabled ? 'minimize' : splitMainState.mode}
disable={leftBarDisabled}
>
<Split {...splitMainState} sticky={30} mode={leftBarDisabled ? 'minimize' : splitMainState.mode} disable={leftBarDisabled}>
<Pane className={s(styles, { pane: true })} basis="250px" main>
<Loader suspense>
<SideBarPanel container={leftBarPanelService.tabsContainer} />
Expand Down
Loading

0 comments on commit 6a653c5

Please sign in to comment.