mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fallback to 'common' tenant if 'tid' not found (#21388)
This commit is contained in:
@@ -474,6 +474,7 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
const homeTenant = tenants.splice(homeTenantIndex, 1);
|
||||
tenants.unshift(homeTenant[0]);
|
||||
}
|
||||
Logger.verbose(`Filtered Tenants: ${tenantList}`);
|
||||
return tenants;
|
||||
} catch (ex) {
|
||||
Logger.error(`Error fetching tenants :${ex}`);
|
||||
@@ -676,10 +677,11 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
//#region data modeling
|
||||
|
||||
public createAccount(tokenClaims: TokenClaims, key: string, tenants: Tenant[]): AzureAccount {
|
||||
Logger.verbose(`Token Claims: ${tokenClaims.name}`);
|
||||
Logger.verbose(`Token Claims acccount: ${tokenClaims.name}, TID: ${tokenClaims.tid}`);
|
||||
tenants.forEach((tenant) => {
|
||||
Logger.verbose(`Tenant ID: ${tenant.id}, Tenant Name: ${tenant.displayName}`);
|
||||
});
|
||||
|
||||
// Determine if this is a microsoft account
|
||||
let accountIssuer = 'unknown';
|
||||
|
||||
@@ -694,9 +696,14 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
const name = tokenClaims.name ?? tokenClaims.email ?? tokenClaims.unique_name ?? tokenClaims.preferred_username;
|
||||
const email = tokenClaims.email ?? tokenClaims.unique_name ?? tokenClaims.preferred_username;
|
||||
|
||||
let owningTenant: Tenant = this.commonTenant; // default to common tenant
|
||||
|
||||
// Read more about tid > https://learn.microsoft.com/azure/active-directory/develop/id-tokens
|
||||
const owningTenant = tenants.find(t => t.id === tokenClaims.tid)
|
||||
?? { 'id': tokenClaims.tid, 'displayName': 'Microsoft Account' };
|
||||
if (tokenClaims.tid) {
|
||||
owningTenant = tenants.find(t => t.id === tokenClaims.tid) ?? { 'id': tokenClaims.tid, 'displayName': 'Microsoft Account' };
|
||||
} else {
|
||||
Logger.info('Could not find tenant information from tokenClaims, falling back to common Tenant.');
|
||||
}
|
||||
|
||||
let displayName = name;
|
||||
if (email) {
|
||||
|
||||
Reference in New Issue
Block a user