mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-19 10:56:04 +08:00
dbeaver/pro#10034 excludes network handler creds if profile is applied for this handler (#4582)
* dbeaver/pro#10034 excludes network handler creds if profile is applied for this handler * dbeaver/pro#10034 introduces external network providers service
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
*/
|
||||
|
||||
import { injectable } from '@cloudbeaver/core-di';
|
||||
|
||||
import type { IConnectionInfoParams } from './CONNECTION_INFO_PARAM_SCHEMA.js';
|
||||
|
||||
export type ConnectionInfoExternalNetworkHandlersProvider = (key: IConnectionInfoParams) => Promise<readonly string[]>;
|
||||
|
||||
@injectable()
|
||||
export class ConnectionInfoExternalNetworkHandlersService {
|
||||
private readonly providerRegistry = new Map<string, ConnectionInfoExternalNetworkHandlersProvider>();
|
||||
|
||||
registerProvider(providerId: string, provider: ConnectionInfoExternalNetworkHandlersProvider): void {
|
||||
this.providerRegistry.set(providerId, provider);
|
||||
}
|
||||
|
||||
async getProvidedHandlers(connectionKey: IConnectionInfoParams): Promise<readonly string[]> {
|
||||
return [...new Set((await Promise.all([...this.providerRegistry.values()].map(provider => provider(connectionKey)))).flat())];
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ export * from './ConnectionInfoCustomOptionsResource.js';
|
||||
export * from './ConnectionInfoPropertiesResource.js';
|
||||
export * from './ConnectionInfoProviderPropertiesResource.js';
|
||||
export * from './ConnectionInfoNetworkHandlersResource.js';
|
||||
export * from './ConnectionInfoExternalNetworkHandlersService.js';
|
||||
export * from './CONNECTIONS_SETTINGS_GROUP.js';
|
||||
export * from './EConnectionFeature.js';
|
||||
export * from './ConnectionsSettingsService.js';
|
||||
|
||||
@@ -23,6 +23,7 @@ import { ConnectionInfoPropertiesResource } from './ConnectionInfoPropertiesReso
|
||||
import { ConnectionInfoOriginResource } from './ConnectionInfoOriginResource.js';
|
||||
import { ConnectionInfoOriginDetailsResource } from './ConnectionInfoOriginDetailsResource.js';
|
||||
import { ConnectionInfoNetworkHandlersResource } from './ConnectionInfoNetworkHandlersResource.js';
|
||||
import { ConnectionInfoExternalNetworkHandlersService } from './ConnectionInfoExternalNetworkHandlersService.js';
|
||||
import { ConnectionInfoAuthPropertiesResource } from './ConnectionInfoAuthPropertiesResource.js';
|
||||
import { ConnectionInfoEventHandler } from './ConnectionInfoEventHandler.js';
|
||||
import { ConnectionInfoCustomOptionsResource } from './ConnectionInfoCustomOptionsResource.js';
|
||||
@@ -77,6 +78,7 @@ export default ModuleRegistry.add({
|
||||
.addSingleton(ConnectionInfoOriginResource)
|
||||
.addSingleton(ConnectionInfoOriginDetailsResource)
|
||||
.addSingleton(ConnectionInfoNetworkHandlersResource)
|
||||
.addSingleton(ConnectionInfoExternalNetworkHandlersService)
|
||||
.addSingleton(ConnectionInfoAuthPropertiesResource)
|
||||
.addSingleton(ConnectionInfoEventHandler)
|
||||
.addSingleton(ConnectionInfoCustomOptionsResource)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* CloudBeaver - Cloud Database Manager
|
||||
* Copyright (C) 2020-2025 DBeaver Corp and others
|
||||
* Copyright (C) 2020-2026 DBeaver Corp and others
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0.
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -10,6 +10,7 @@ import { importLazyComponent } from '@cloudbeaver/core-blocks';
|
||||
import {
|
||||
type Connection,
|
||||
ConnectionInfoAuthPropertiesResource,
|
||||
ConnectionInfoExternalNetworkHandlersService,
|
||||
type ConnectionInfoNetworkHandlers,
|
||||
ConnectionInfoNetworkHandlersResource,
|
||||
ConnectionInfoResource,
|
||||
@@ -32,6 +33,7 @@ const DatabaseAuthDialog = importLazyComponent(() => import('./DatabaseAuthDialo
|
||||
ConnectionInfoResource,
|
||||
ConnectionInfoNetworkHandlersResource,
|
||||
ConnectionInfoAuthPropertiesResource,
|
||||
ConnectionInfoExternalNetworkHandlersService,
|
||||
CommonDialogService,
|
||||
AuthProviderService,
|
||||
UserInfoResource,
|
||||
@@ -44,6 +46,7 @@ export class ConnectionAuthService {
|
||||
private readonly connectionInfoResource: ConnectionInfoResource,
|
||||
private readonly connectionInfoNetworkHandlersResource: ConnectionInfoNetworkHandlersResource,
|
||||
private readonly connectionInfoAuthPropertiesResource: ConnectionInfoAuthPropertiesResource,
|
||||
private readonly connectionInfoExternalNetworkHandlersService: ConnectionInfoExternalNetworkHandlersService,
|
||||
private readonly commonDialogService: CommonDialogService,
|
||||
private readonly authProviderService: AuthProviderService,
|
||||
userInfoResource: UserInfoResource,
|
||||
@@ -115,6 +118,7 @@ export class ConnectionAuthService {
|
||||
this.networkHandlerResource.load(CachedMapAllKey),
|
||||
]);
|
||||
|
||||
const externalHandlers = new Set(await this.connectionInfoExternalNetworkHandlersService.getProvidedHandlers(key));
|
||||
const networkHandlers = connectionNetworkHandlers
|
||||
.networkHandlersConfig!.filter(handler => {
|
||||
const target = handlers.find(h => h.id === handler.id);
|
||||
@@ -123,7 +127,7 @@ export class ConnectionAuthService {
|
||||
return false;
|
||||
}
|
||||
|
||||
return handler.enabled && (!handler.savePassword || resetCredentials);
|
||||
return !externalHandlers.has(handler.id) && handler.enabled && (!handler.savePassword || resetCredentials);
|
||||
})
|
||||
.map(handler => handler.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user