diff --git a/src/Accounts/Authentication/Authentication/Parameters/DeviceCodeParameters.cs b/src/Accounts/Authentication/Authentication/Parameters/DeviceCodeParameters.cs index 2c7cd1460cd7..07f10d4ff1d6 100644 --- a/src/Accounts/Authentication/Authentication/Parameters/DeviceCodeParameters.cs +++ b/src/Accounts/Authentication/Authentication/Parameters/DeviceCodeParameters.cs @@ -22,6 +22,8 @@ public class DeviceCodeParameters : AuthenticationParameters public string HomeAccountId { get; set; } + public string ClaimsChallenge { get; set; } + public DeviceCodeParameters( PowerShellTokenCacheProvider tokenCacheProvider, IAzureEnvironment environment, @@ -29,10 +31,12 @@ public DeviceCodeParameters( string tenantId, string resourceId, string userId, - string homeAccountId) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId) + string homeAccountId, + string claimsChallenge) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId) { UserId = userId; HomeAccountId = homeAccountId; + ClaimsChallenge = claimsChallenge; } } } diff --git a/src/Accounts/Authentication/Authentication/Parameters/InteractiveParameters.cs b/src/Accounts/Authentication/Authentication/Parameters/InteractiveParameters.cs index 00d8fbdd9e6c..8514840866d5 100644 --- a/src/Accounts/Authentication/Authentication/Parameters/InteractiveParameters.cs +++ b/src/Accounts/Authentication/Authentication/Parameters/InteractiveParameters.cs @@ -21,8 +21,6 @@ public class InteractiveParameters : DeviceCodeParameters { public Action PromptAction { get; set; } - public string ClaimsChallenge { get; set; } - public InteractiveParameters( PowerShellTokenCacheProvider tokenCacheProvider, IAzureEnvironment environment, @@ -32,10 +30,9 @@ public InteractiveParameters( string userId, string homeAccountId, Action promptAction, - string claimsChallenge) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId, userId, homeAccountId) + string claimsChallenge) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId, userId, homeAccountId, claimsChallenge) { PromptAction = promptAction; - ClaimsChallenge = claimsChallenge; } } } diff --git a/src/Accounts/Authentication/Authentication/Parameters/InteractiveWamParameters.cs b/src/Accounts/Authentication/Authentication/Parameters/InteractiveWamParameters.cs index b9a428d24f2d..32aad6c5cec7 100644 --- a/src/Accounts/Authentication/Authentication/Parameters/InteractiveWamParameters.cs +++ b/src/Accounts/Authentication/Authentication/Parameters/InteractiveWamParameters.cs @@ -21,8 +21,6 @@ public class InteractiveWamParameters : DeviceCodeParameters { public Action PromptAction { get; set; } - public string ClaimsChallenge { get; set; } - public InteractiveWamParameters( PowerShellTokenCacheProvider tokenCacheProvider, IAzureEnvironment environment, @@ -32,10 +30,9 @@ public InteractiveWamParameters( string userId, string homeAccountId, Action promptAction, - string claimsChallenge) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId, userId, homeAccountId) + string claimsChallenge) : base(tokenCacheProvider, environment, tokenCache, tenantId, resourceId, userId, homeAccountId, claimsChallenge) { PromptAction = promptAction; - ClaimsChallenge = claimsChallenge; } } } diff --git a/src/Accounts/Authentication/Factories/AuthenticationFactory.cs b/src/Accounts/Authentication/Factories/AuthenticationFactory.cs index c6fdb5f90992..9975efcdd0dd 100644 --- a/src/Accounts/Authentication/Factories/AuthenticationFactory.cs +++ b/src/Accounts/Authentication/Factories/AuthenticationFactory.cs @@ -662,7 +662,7 @@ private AuthenticationParameters GetAuthenticationParameters( if (account.IsPropertySet("UseDeviceAuth")) { - return new DeviceCodeParameters(tokenCacheProvider, environment, tokenCache, tenant, resourceId, account.Id, homeAccountId); + return new DeviceCodeParameters(tokenCacheProvider, environment, tokenCache, tenant, resourceId, account.Id, homeAccountId, claimsChallenge); } else if (account.IsPropertySet(AzureAccount.Property.UsePasswordAuth)) { diff --git a/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs b/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs index 2584b7d7173f..cb789cb08fdb 100644 --- a/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs +++ b/src/Accounts/Authenticators/DeviceCodeAuthenticator.cs @@ -43,8 +43,9 @@ public override Task Authenticate(AuthenticationParameters paramet var scopes = AuthenticationHelpers.GetScope(onPremise, resource); var clientId = Constants.PowerShellClientId; var authority = parameters.Environment.ActiveDirectoryAuthority; + var claimsChallenge = deviceCodeParameters.ClaimsChallenge; - var requestContext = new TokenRequestContext(scopes, isCaeEnabled: true); + var requestContext = new TokenRequestContext(scopes, claims: claimsChallenge, isCaeEnabled: true); DeviceCodeCredentialOptions options = new DeviceCodeCredentialOptions() { DeviceCodeCallback = DeviceCodeFunc,