Fix azure account tree subscription check (#16822)

* Fix azure account tree subscription check

* comment
This commit is contained in:
Charles Gagnon
2021-08-18 14:35:16 -07:00
committed by GitHub
parent df49d67f7d
commit ea6e03f826
14 changed files with 60 additions and 18 deletions

16
src/sql/azdata.d.ts vendored
View File

@@ -2175,6 +2175,20 @@ declare module 'azdata' {
*/
export function getSecurityToken(account: Account, resource?: AzureResource): Thenable<{ [key: string]: any }>;
/**
* The token used to authenticate an account.
*/
export interface AccountSecurityToken {
/**
* The token to use
*/
token: string,
/**
* What type of token this is (such as Bearer)
*/
tokenType?: string | undefined
}
/**
* Generates a security token by asking the account's provider
* @param account The account to retrieve the security token for
@@ -2182,7 +2196,7 @@ declare module 'azdata' {
* @param resource Type of resource to get the security token for (defaults to
* AzureResource.ResourceManagement if not given)
*/
export function getAccountSecurityToken(account: Account, tenantId: string, resource: AzureResource): Thenable<{ token: string, tokenType?: string | undefined } | undefined>;
export function getAccountSecurityToken(account: Account, tenantId: string, resource: AzureResource): Thenable<AccountSecurityToken | undefined>;
/**
* An [event](#Event) which fires when the accounts have changed.

View File

@@ -836,7 +836,7 @@ declare module 'azdata' {
* @param resource The resource to get the token for
* @return Promise to return a security token object
*/
getAccountSecurityToken(account: Account, tenant: string, resource: AzureResource): Thenable<{ token: string } | undefined>;
getAccountSecurityToken(account: Account, tenant: string, resource: AzureResource): Thenable<accounts.AccountSecurityToken | undefined>;
}
export interface AccountKey {

View File

@@ -25,7 +25,7 @@ export interface IAccountManagementService {
* @deprecated
*/
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Promise<{ [key: string]: { token: string } } | undefined>;
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<{ token: string } | undefined>;
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<azdata.accounts.AccountSecurityToken | undefined>;
removeAccount(accountKey: azdata.AccountKey): Promise<boolean>;
removeAccounts(): Promise<boolean>;
refreshAccount(account: azdata.Account): Promise<azdata.Account>;

View File

@@ -55,7 +55,7 @@ export class TestAccountManagementService implements IAccountManagementService {
return Promise.resolve([]);
}
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<{ token: string }> {
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<azdata.accounts.AccountSecurityToken> {
return Promise.resolve(undefined!);
}

View File

@@ -78,7 +78,7 @@ export class MainThreadAccountManagement extends Disposable implements MainThrea
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}> {
return self._proxy.$getSecurityToken(account, resource);
},
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Thenable<{ token: string }> {
getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Thenable<azdata.accounts.AccountSecurityToken> {
return self._proxy.$getAccountSecurityToken(account, tenant, resource);
},
initialize(restoredAccounts: azdata.Account[]): Thenable<azdata.Account[]> {

View File

@@ -104,7 +104,7 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
});
}
public override $getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource = AzureResource.ResourceManagement): Thenable<{ token: string }> {
public override $getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource = AzureResource.ResourceManagement): Thenable<azdata.accounts.AccountSecurityToken> {
return this.getAllProvidersAndAccounts().then(providerAndAccounts => {
const providerAndAccount = providerAndAccounts.find(providerAndAccount => providerAndAccount.account.key.accountId === account.key.accountId);
if (providerAndAccount) {

View File

@@ -165,7 +165,7 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
getSecurityToken(account: azdata.Account, resource?: azdata.AzureResource): Thenable<{}> {
return extHostAccountManagement.$getSecurityToken(account, resource);
},
getAccountSecurityToken(account: azdata.Account, tenant: string, resource?: azdata.AzureResource): Thenable<{ token: string }> {
getAccountSecurityToken(account: azdata.Account, tenant: string, resource?: azdata.AzureResource): Thenable<azdata.accounts.AccountSecurityToken> {
return extHostAccountManagement.$getAccountSecurityToken(account, tenant, resource);
},
onDidChangeAccounts(listener: (e: azdata.DidChangeAccountsParams) => void, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {

View File

@@ -32,7 +32,7 @@ export abstract class ExtHostAccountManagementShape {
$autoOAuthCancelled(handle: number): Thenable<void> { throw ni(); }
$clear(handle: number, accountKey: azdata.AccountKey): Thenable<void> { throw ni(); }
$getSecurityToken(account: azdata.Account, resource?: azdata.AzureResource): Thenable<{}> { throw ni(); }
$getAccountSecurityToken(account: azdata.Account, tenant: string, resource?: azdata.AzureResource): Thenable<{ token: string }> { throw ni(); }
$getAccountSecurityToken(account: azdata.Account, tenant: string, resource?: azdata.AzureResource): Thenable<azdata.accounts.AccountSecurityToken> { throw ni(); }
$initialize(handle: number, restoredAccounts: azdata.Account[]): Thenable<azdata.Account[]> { throw ni(); }
$prompt(handle: number): Thenable<azdata.Account | azdata.PromptFailedResult> { throw ni(); }
$refresh(handle: number, account: azdata.Account): Thenable<azdata.Account | azdata.PromptFailedResult> { throw ni(); }

View File

@@ -246,7 +246,7 @@ export class AccountManagementService implements IAccountManagementService {
* @param resource The resource to get the security token for
* @return Promise to return the security token
*/
public getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<{ token: string } | undefined> {
public getAccountSecurityToken(account: azdata.Account, tenant: string, resource: azdata.AzureResource): Promise<azdata.accounts.AccountSecurityToken | undefined> {
return this.doWithProvider(account.key.providerId, provider => {
return Promise.resolve(provider.provider.getAccountSecurityToken(account, tenant, resource));
});