Skip to content

Commit cb264ab

Browse files
committed
Fix empty/whitespace azureTenantId falling through to malformed URL
??-coalescing only substitutes for null/undefined, so an empty or whitespace-only azureTenantId would build `https://login.microsoftonline.com//v2.0/...` (double slash) and surface as an opaque Azure 404. Trim first and use || so any falsy/blank value falls back to /organizations/ like the unset case. Co-authored-by: Isaac
1 parent f3fdcde commit cb264ab

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/connection/auth/DatabricksOAuth/OAuthManager.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ export class AzureOAuthManager extends OAuthManager {
277277
public static datatricksAzureApp = '2ff814a6-3304-4ab8-85cb-cd0e6f879c1d';
278278

279279
protected getOIDCConfigUrl(): string {
280-
const tenantPath = this.options.azureTenantId ?? 'organizations';
280+
// Use logical OR so empty / whitespace-only azureTenantId also falls back to /organizations/
281+
// (`??` only substitutes for null/undefined, leaving `''` to produce a malformed `//v2.0/...` URL).
282+
const tenantPath = this.options.azureTenantId?.trim() || 'organizations';
281283
return `https://login.microsoftonline.com/${tenantPath}/v2.0/.well-known/openid-configuration`;
282284
}
283285

tests/unit/connection/auth/DatabricksOAuth/OAuthManager.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,14 @@ describe('AzureOAuthManager (tenant awareness)', () => {
547547
const url = call<string>(mgr, 'getOIDCConfigUrl');
548548
expect(url).to.equal(`https://login.microsoftonline.com/${tenant}/v2.0/.well-known/openid-configuration`);
549549
});
550+
551+
it('falls back to /organizations/ when azureTenantId is empty or whitespace', () => {
552+
for (const tenant of ['', ' ']) {
553+
const mgr = makeAzure({ azureTenantId: tenant });
554+
const url = call<string>(mgr, 'getOIDCConfigUrl');
555+
expect(url).to.equal('https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration');
556+
}
557+
});
550558
});
551559

552560
describe('getScopes — resource ID is always the Azure Login App, never a tenant GUID', () => {

0 commit comments

Comments
 (0)