Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions sdk/identity/Azure.Identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- TenantId is now configured via MSAL's `WithTenantId` instead of `WithTenantIdFromAuthority` to prevent malformed Uris to the authority.

### Other Changes

## 1.16.0 (2025-09-09)
Expand Down
15 changes: 0 additions & 15 deletions sdk/identity/Azure.Identity/src/MsalClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,5 @@ await _clientWithCaeAsyncLock.GetLockOrValueAsync(true, default).ConfigureAwait(

return asyncLock.HasValue ? asyncLock.Value.Cache : null;
}

public UriBuilder BuildTenantIdWithAuthorityHost(string tenantId)
{
UriBuilder uriBuilder = new(AuthorityHost);
if (uriBuilder.Path.EndsWith("/"))
{
uriBuilder.Path += tenantId;
}
else
{
uriBuilder.Path = uriBuilder.Path + "/" + tenantId;
}

return uriBuilder;
}
}
}
12 changes: 4 additions & 8 deletions sdk/identity/Azure.Identity/src/MsalConfidentialClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ public virtual async ValueTask<AuthenticationResult> AcquireTokenForClientCoreAs

if (!string.IsNullOrEmpty(tenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
if (!string.IsNullOrEmpty(claims))
{
Expand Down Expand Up @@ -211,8 +210,7 @@ public virtual async ValueTask<AuthenticationResult> AcquireTokenSilentCoreAsync
var builder = client.AcquireTokenSilent(scopes, account);
if (!string.IsNullOrEmpty(tenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
if (!string.IsNullOrEmpty(claims))
{
Expand Down Expand Up @@ -254,8 +252,7 @@ public virtual async ValueTask<AuthenticationResult> AcquireTokenByAuthorization

if (!string.IsNullOrEmpty(tenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
if (!string.IsNullOrEmpty(claims))
{
Expand Down Expand Up @@ -297,8 +294,7 @@ public virtual async ValueTask<AuthenticationResult> AcquireTokenOnBehalfOfCoreA

if (!string.IsNullOrEmpty(tenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
if (!string.IsNullOrEmpty(claims))
{
Expand Down
18 changes: 6 additions & 12 deletions sdk/identity/Azure.Identity/src/MsalPublicClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenSilentCoreAs
}
if (tenantId != null)
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}

if (context.IsProofOfPossessionEnabled)
Expand Down Expand Up @@ -182,8 +181,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenSilentCoreAs

if (tenantId != null || record.TenantId != null)
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId ?? record.TenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId ?? record.TenantId);
}

if (!string.IsNullOrEmpty(claims))
Expand Down Expand Up @@ -284,8 +282,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenInteractiveC
}
if (tenantId != null)
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
if (browserOptions != null)
{
Expand Down Expand Up @@ -328,8 +325,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenByUsernamePa
}
if (!string.IsNullOrEmpty(tenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(tenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(tenantId);
}
return await builder.ExecuteAsync(async, cancellationToken)
.ConfigureAwait(false);
Expand All @@ -353,8 +349,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenWithDeviceCo
}
if (!string.IsNullOrEmpty(TenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(TenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(TenantId);
}

return await builder.ExecuteAsync(async, cancellationToken)
Expand All @@ -380,8 +375,7 @@ protected virtual async ValueTask<AuthenticationResult> AcquireTokenByRefreshTok

if (!string.IsNullOrEmpty(TenantId))
{
UriBuilder uriBuilder = BuildTenantIdWithAuthorityHost(TenantId);
builder.WithTenantIdFromAuthority(uriBuilder.Uri);
builder.WithTenantId(TenantId);
}

return await builder.ExecuteAsync(async, cancellationToken)
Expand Down