Skip to content

Commit 941d363

Browse files
authored
Mark UsernamePasswordCredential as obsolete (Azure#48355)
1 parent 0a7f4d6 commit 941d363

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

sdk/identity/Azure.Identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Bugs Fixed
1010

1111
### Other Changes
12+
- Marked `UsernamePasswordCredential` as obsolete because Resource Owner Password Credentials (ROPC) token grant flow is incompatible with multifactor authentication (MFA), which Microsoft Entra ID requires for all tenants. See https://aka.ms/azsdk/identity/mfa for details about MFA enforcement and migration guidance.
1213

1314
## 1.14.0-beta.1 (2025-02-11)
1415

sdk/identity/Azure.Identity/api/Azure.Identity.net8.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ protected UnsafeTokenCacheOptions() { }
422422
protected internal virtual System.Threading.Tasks.Task<Azure.Identity.TokenCacheData> RefreshCacheAsync(Azure.Identity.TokenCacheRefreshArgs args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
423423
protected internal abstract System.Threading.Tasks.Task TokenCacheUpdatedAsync(Azure.Identity.TokenCacheUpdatedArgs tokenCacheUpdatedArgs);
424424
}
425+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
426+
[System.ObsoleteAttribute("This credential is deprecated because it doesn't support multifactor authentication (MFA). See https://aka.ms/azsdk/identity/mfa for details about MFA enforcement for Microsoft Entra ID and migration guidance.")]
425427
public partial class UsernamePasswordCredential : Azure.Core.TokenCredential
426428
{
427429
protected UsernamePasswordCredential() { }

sdk/identity/Azure.Identity/api/Azure.Identity.netstandard2.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ protected UnsafeTokenCacheOptions() { }
419419
protected internal virtual System.Threading.Tasks.Task<Azure.Identity.TokenCacheData> RefreshCacheAsync(Azure.Identity.TokenCacheRefreshArgs args, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
420420
protected internal abstract System.Threading.Tasks.Task TokenCacheUpdatedAsync(Azure.Identity.TokenCacheUpdatedArgs tokenCacheUpdatedArgs);
421421
}
422+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
423+
[System.ObsoleteAttribute("This credential is deprecated because it doesn't support multifactor authentication (MFA). See https://aka.ms/azsdk/identity/mfa for details about MFA enforcement for Microsoft Entra ID and migration guidance.")]
422424
public partial class UsernamePasswordCredential : Azure.Core.TokenCredential
423425
{
424426
protected UsernamePasswordCredential() { }

sdk/identity/Azure.Identity/src/Credentials/EnvironmentCredential.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ internal EnvironmentCredential(CredentialPipeline pipeline, TokenCredentialOptio
114114
}
115115
else if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
116116
{
117+
#pragma warning disable CS0618 // Type or member is obsolete
117118
Credential = new UsernamePasswordCredential(username, password, tenantId, clientId, envCredOptions, _pipeline, envCredOptions.MsalPublicClient);
119+
#pragma warning restore CS0618 // Type or member is obsolete
118120
}
119121
}
120122
}

sdk/identity/Azure.Identity/src/Credentials/UsernamePasswordCredential.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Azure.Core.Pipeline;
11+
using System.ComponentModel;
1112

1213
namespace Azure.Identity
1314
{
@@ -16,6 +17,8 @@ namespace Azure.Identity
1617
/// credential will fail to get a token throwing an <see cref="AuthenticationFailedException"/>. Also, this credential requires a high degree of
1718
/// trust and is not recommended outside of prototyping when more secure credentials can be used.
1819
/// </summary>
20+
[EditorBrowsable(EditorBrowsableState.Never)]
21+
[Obsolete("This credential is deprecated because it doesn't support multifactor authentication (MFA). See https://aka.ms/azsdk/identity/mfa for details about MFA enforcement for Microsoft Entra ID and migration guidance.")]
1922
public class UsernamePasswordCredential : TokenCredential
2023
{
2124
private const string NoDefaultScopeMessage = "Authenticating in this environment requires specifying a TokenRequestContext.";

sdk/identity/Azure.Identity/tests/Azure.Identity.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
55
<IsPackable>false</IsPackable>
6+
<NoWarn>$(NoWarn);0618</NoWarn>
67
</PropertyGroup>
78

89
<ItemGroup>

0 commit comments

Comments
 (0)