Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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())];
}
}
1 change: 1 addition & 0 deletions webapp/packages/core-connections/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions webapp/packages/core-connections/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -77,6 +78,7 @@ export default ModuleRegistry.add({
.addSingleton(ConnectionInfoOriginResource)
.addSingleton(ConnectionInfoOriginDetailsResource)
.addSingleton(ConnectionInfoNetworkHandlersResource)
.addSingleton(ConnectionInfoExternalNetworkHandlersService)
.addSingleton(ConnectionInfoAuthPropertiesResource)
.addSingleton(ConnectionInfoEventHandler)
.addSingleton(ConnectionInfoCustomOptionsResource)
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -10,6 +10,7 @@ import { importLazyComponent } from '@cloudbeaver/core-blocks';
import {
type Connection,
ConnectionInfoAuthPropertiesResource,
ConnectionInfoExternalNetworkHandlersService,
type ConnectionInfoNetworkHandlers,
ConnectionInfoNetworkHandlersResource,
ConnectionInfoResource,
Expand All @@ -29,6 +30,7 @@ const DatabaseAuthDialog = importLazyComponent(() => import('./DatabaseAuthDialo
ConnectionInfoResource,
ConnectionInfoNetworkHandlersResource,
ConnectionInfoAuthPropertiesResource,
ConnectionInfoExternalNetworkHandlersService,
CommonDialogService,
AuthProviderService,
UserInfoResource,
Expand All @@ -40,6 +42,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,
Expand Down Expand Up @@ -108,8 +111,9 @@ export class ConnectionAuthService {
this.connectionInfoResource.load(key),
]);

const externalHandlers = new Set(await this.connectionInfoExternalNetworkHandlersService.getProvidedHandlers(key));
const networkHandlers = connectionNetworkHandlers
.networkHandlersConfig!.filter(handler => handler.enabled && (!handler.savePassword || resetCredentials))
.networkHandlersConfig!.filter(handler => !externalHandlers.has(handler.id) && handler.enabled && (!handler.savePassword || resetCredentials))
.map(handler => handler.id);

if (connectionAuthProperties.authNeeded || (connectionAuthProperties.credentialsSaved && resetCredentials) || networkHandlers.length > 0) {
Expand Down
Loading