mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 17:22:51 -05:00
Enable SQL Auth Provider support (#21903)
This commit is contained in:
@@ -403,6 +403,24 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
return this.tryConnect(connection, input, options);
|
||||
}
|
||||
|
||||
public async fixProfile(profile?: interfaces.IConnectionProfile): Promise<interfaces.IConnectionProfile> {
|
||||
if (profile) {
|
||||
if (profile.authenticationType !== undefined && profile.authenticationType === '') {
|
||||
// we need to set auth type here, because it's value is part of the session key
|
||||
profile.authenticationType = this.getDefaultAuthenticationTypeId(profile.providerName);
|
||||
}
|
||||
|
||||
// If this is Azure MFA Authentication, fix username to azure Account user. Falls back to current user name.
|
||||
// This is required, as by default, server login / administrator is the username.
|
||||
if (profile.authenticationType === 'AzureMFA') {
|
||||
let accounts = await this._accountManagementService?.getAccounts();
|
||||
profile.userName = accounts?.find(a => a.key.accountId === profile.azureAccount)?.displayInfo.displayName
|
||||
?? profile.userName;
|
||||
}
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* If there's already a connection for given profile and purpose, returns the ownerUri for the connection
|
||||
* otherwise tries to make a connection and returns the owner uri when connection is complete
|
||||
|
||||
@@ -43,13 +43,13 @@ export class OEShimService extends Disposable implements IOEShimService {
|
||||
@IObjectExplorerService private oe: IObjectExplorerService,
|
||||
@IConnectionManagementService private cm: IConnectionManagementService,
|
||||
@ICapabilitiesService private capabilities: ICapabilitiesService,
|
||||
@IConfigurationService private configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
private async createSession(viewId: string, providerId: string, node: ITreeItem): Promise<string> {
|
||||
let connProfile = new ConnectionProfile(this.capabilities, node.payload);
|
||||
let payload = await this.cm.fixProfile(node.payload);
|
||||
let connProfile = new ConnectionProfile(this.capabilities, payload);
|
||||
connProfile.saveProfile = false;
|
||||
if (this.cm.providerRegistered(providerId)) {
|
||||
connProfile = await this.connectOrPrompt(connProfile);
|
||||
@@ -119,9 +119,7 @@ export class OEShimService extends Disposable implements IOEShimService {
|
||||
|
||||
public async getChildren(node: ITreeItem, viewId: string): Promise<ITreeItem[]> {
|
||||
if (node.payload) {
|
||||
if (node.payload.authenticationType !== undefined && node.payload.authenticationType === '') {
|
||||
node.payload.authenticationType = this.getDefaultAuthenticationType(this.configurationService); // we need to set auth type here, because it's value is part of the session key
|
||||
}
|
||||
node.payload = await this.cm.fixProfile(node.payload);
|
||||
|
||||
if (node.sessionId === undefined) {
|
||||
node.sessionId = await this.createSession(viewId, node.childProvider!, node);
|
||||
|
||||
Reference in New Issue
Block a user