Skip to content

Commit ee54b4c

Browse files
msJinLeiisra-feldingmeng-xue
authored
Login interactively using WAM (#17466)
* WAM * address review comments Co-authored-by: Yeming Liu <[email protected]> Co-authored-by: Dingmeng Xue <[email protected]>
1 parent a54e177 commit ee54b4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+452
-63
lines changed

.azure-pipelines/security-tools.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
condition: eq(variables.IsGenerateBased, true)
3232
inputs:
3333
versionSpec: 14.17.1
34-
34+
3535
- task: PowerShell@2
3636
displayName: Install autorest
3737
condition: eq(variables.IsGenerateBased, true)
@@ -54,6 +54,13 @@ jobs:
5454
scanFolder: SecurityTmp
5555
suppressionsFile: tools/SecurityTools/CredScanSuppressions.json
5656

57+
- task: PowerShell@2
58+
displayName: Copy PDB for BinSkim
59+
inputs:
60+
targetType: inline
61+
script: ./src/lib/pdb/CopyPdbToArtifacts.ps1
62+
pwsh: true
63+
5764
- task: securedevelopmentteam.vss-secure-development-tools.build-task-binskim.BinSkim@3
5865
displayName: Run BinSkim
5966
inputs:

src/Accounts/Accounts/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020

2121
## Upcoming Release
22+
* Supported Web Account Manager (WAM) as an opt-in interactive login experience. Enable it by `Update-AzConfig -EnableLoginByWam $true`.
2223
* Optimized the mechanism for assembly loading.
2324
* Enabled AzKeyStore with keyring in Linux.
2425
* Fixed a typo in GetAzureRmContextAutosaveSetting.cs changing the cmdlet class name to GetAzureRmContextAutosaveSetting

src/Accounts/Accounts/help/Clear-AzConfig.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Clear-AzConfig [-Force] [-PassThru] [-AppliesTo <String>] [-Scope <ConfigScope>]
2222
```
2323
Clear-AzConfig [-PassThru] [-AppliesTo <String>] [-Scope <ConfigScope>]
2424
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [-DefaultSubscriptionForLogin]
25-
[-DisplayBreakingChangeWarning] [-DisplaySurveyMessage] [-EnableDataCollection] [<CommonParameters>]
25+
[-DisplayBreakingChangeWarning] [-DisplaySurveyMessage] [-EnableDataCollection] [-EnableLoginByWam]
26+
[<CommonParameters>]
2627
```
2728

2829
## DESCRIPTION
@@ -145,6 +146,24 @@ Accept pipeline input: False
145146
Accept wildcard characters: False
146147
```
147148
149+
### -EnableLoginByWam
150+
\[Preview\] When enabled, Web Account Manager (WAM) will be the default interactive login experience.
151+
It will fall back to using the browser if the platform does not support WAM.
152+
Note that this feature is under preview. Microsoft Account (MSA) is currently not supported.
153+
Feel free to reach out to Azure PowerShell team if you have any feedbacks: https://aka.ms/azpsissue
154+
155+
```yaml
156+
Type: System.Management.Automation.SwitchParameter
157+
Parameter Sets: ClearByKey
158+
Aliases:
159+
160+
Required: False
161+
Position: Named
162+
Default value: None
163+
Accept pipeline input: False
164+
Accept wildcard characters: False
165+
```
166+
148167
### -Force
149168
Do not ask for confirmation when clearing all configs.
150169
@@ -183,7 +202,7 @@ By default it is CurrentUser.
183202
Type: Microsoft.Azure.PowerShell.Common.Config.ConfigScope
184203
Parameter Sets: (All)
185204
Aliases:
186-
Accepted values: CurrentUser, Process
205+
Accepted values: CurrentUser, Process, Default, Environment
187206

188207
Required: False
189208
Position: Named

src/Accounts/Accounts/help/Connect-AzAccount.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,21 @@ Account SubscriptionName TenantId Env
251251
xxxxxxxx-xxxx-xxxx-xxxxxxxx Subscription1 yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyy AzureCloud
252252
```
253253

254+
### Example 10: Connect interactively using WAM
255+
256+
This example demonstrates how to enable the config for WAM (Web Account Manager) and use it to connect to Azure.
257+
258+
```powershell
259+
Update-AzConfig -EnableLoginByWam $true
260+
Connect-AzAccount
261+
```
262+
263+
```Output
264+
Account SubscriptionName TenantId Environment
265+
------- ---------------- -------- -----------
266+
xxxxxxxx-xxxx-xxxx-xxxxxxxx Subscription1 yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyy AzureCloud
267+
```
268+
254269
## PARAMETERS
255270

256271
### -AccessToken

src/Accounts/Accounts/help/Get-AzConfig.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Gets the configs of Azure PowerShell.
1515
```
1616
Get-AzConfig [-AppliesTo <String>] [-Scope <ConfigScope>] [-DefaultProfile <IAzureContextContainer>]
1717
[-DefaultSubscriptionForLogin] [-DisplayBreakingChangeWarning] [-DisplaySurveyMessage] [-EnableDataCollection]
18-
[<CommonParameters>]
18+
[-EnableLoginByWam] [<CommonParameters>]
1919
```
2020

2121
## DESCRIPTION
@@ -157,6 +157,24 @@ Accept pipeline input: False
157157
Accept wildcard characters: False
158158
```
159159
160+
### -EnableLoginByWam
161+
\[Preview\] When enabled, Web Account Manager (WAM) will be the default interactive login experience.
162+
It will fall back to using the browser if the platform does not support WAM.
163+
Note that this feature is under preview. Microsoft Account (MSA) is currently not supported.
164+
Feel free to reach out to Azure PowerShell team if you have any feedbacks: https://aka.ms/azpsissue
165+
166+
```yaml
167+
Type: System.Management.Automation.SwitchParameter
168+
Parameter Sets: (All)
169+
Aliases:
170+
171+
Required: False
172+
Position: Named
173+
Default value: None
174+
Accept pipeline input: False
175+
Accept wildcard characters: False
176+
```
177+
160178
### -Scope
161179
Determines the scope of config changes, for example, whether changes apply only to the current process, or to all sessions started by this user.
162180
By default it is CurrentUser.

src/Accounts/Accounts/help/Update-AzConfig.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Updates the configs of Azure PowerShell.
1515
```
1616
Update-AzConfig [-AppliesTo <String>] [-Scope <ConfigScope>] [-DefaultProfile <IAzureContextContainer>]
1717
[-WhatIf] [-Confirm] [-DefaultSubscriptionForLogin <String>] [-DisplayBreakingChangeWarning <Boolean>]
18-
[-DisplaySurveyMessage <Boolean>] [-EnableDataCollection <Boolean>] [<CommonParameters>]
18+
[-DisplaySurveyMessage <Boolean>] [-EnableDataCollection <Boolean>] [-EnableLoginByWam <Boolean>]
19+
[<CommonParameters>]
1920
```
2021

2122
## DESCRIPTION
@@ -168,6 +169,24 @@ Accept pipeline input: True (ByPropertyName)
168169
Accept wildcard characters: False
169170
```
170171
172+
### -EnableLoginByWam
173+
\[Preview\] When enabled, Web Account Manager (WAM) will be the default interactive login experience.
174+
It will fall back to using the browser if the platform does not support WAM.
175+
Note that this feature is under preview. Microsoft Account (MSA) is currently not supported.
176+
Feel free to reach out to Azure PowerShell team if you have any feedbacks: https://aka.ms/azpsissue
177+
178+
```yaml
179+
Type: System.Boolean
180+
Parameter Sets: (All)
181+
Aliases:
182+
183+
Required: False
184+
Position: Named
185+
Default value: None
186+
Accept pipeline input: True (ByPropertyName)
187+
Accept wildcard characters: False
188+
```
189+
171190
### -Scope
172191
Determines the scope of config changes, for example, whether changes apply only to the current process, or to all sessions started by this user.
173192
By default it is CurrentUser.
@@ -176,7 +195,7 @@ By default it is CurrentUser.
176195
Type: Microsoft.Azure.PowerShell.Common.Config.ConfigScope
177196
Parameter Sets: (All)
178197
Aliases:
179-
Accepted values: CurrentUser, Process
198+
Accepted values: CurrentUser, Process, Default, Environment
180199

181200
Required: False
182201
Position: Named

src/Accounts/AssemblyLoading/ConditionalAssemblyProvider.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ public static void Initialize(string rootPath, IConditionalAssemblyContext conte
4343
// todo: consider moving the list to a standalone config file
4444
#region AssemblyList
4545
CreateAssembly("netcoreapp2.1", "Azure.Core", "1.25.0.0").WithPowerShellCore(),
46-
CreateAssembly("netcoreapp2.1", "Microsoft.Identity.Client", "4.46.2.0").WithPowerShellCore(),
46+
CreateAssembly("netcoreapp2.1", "Microsoft.Identity.Client", "4.49.1.0").WithPowerShellCore(),
4747
CreateAssembly("netcoreapp3.1", "Microsoft.Identity.Client.Extensions.Msal", "2.23.0.0").WithPowerShellCore(),
4848

4949
CreateAssembly("netstandard2.0", "Azure.Identity", "1.6.1.0"),
50+
CreateAssembly("netstandard2.0", "Azure.Identity.BrokeredAuthentication", "1.0.0.0"),
5051
CreateAssembly("netstandard2.0", "Microsoft.Bcl.AsyncInterfaces", "1.0.0.0"),
52+
CreateAssembly("netstandard2.0", "Microsoft.Identity.Client.Broker", "4.49.1.0"),
53+
CreateAssembly("netstandard2.0", "Microsoft.Identity.Client.NativeInterop", "0.13.3.0"),
5154
CreateAssembly("netstandard2.0", "Microsoft.IdentityModel.Abstractions", "6.22.1.0"),
5255
CreateAssembly("netstandard2.0", "System.Memory.Data", "1.0.2.0"),
5356
CreateAssembly("netstandard2.0", "System.Text.Json", "4.0.1.2"),
@@ -62,7 +65,7 @@ public static void Initialize(string rootPath, IConditionalAssemblyContext conte
6265
CreateAssembly("netstandard2.0", "System.Threading.Tasks.Extensions", "4.2.0.1").WithWindowsPowerShell(),
6366

6467
CreateAssembly("netfx", "Azure.Core", "1.25.0.0").WithWindowsPowerShell(),
65-
CreateAssembly("netfx", "Microsoft.Identity.Client", "4.46.2.0").WithWindowsPowerShell(),
68+
CreateAssembly("netfx", "Microsoft.Identity.Client", "4.49.1.0").WithWindowsPowerShell(),
6669
CreateAssembly("netfx", "Microsoft.Identity.Client.Extensions.Msal", "2.23.0.0").WithWindowsPowerShell(),
6770
CreateAssembly("netfx", "Newtonsoft.Json", "12.0.0.0").WithWindowsPowerShell(),
6871
CreateAssembly("netfx", "System.Diagnostics.DiagnosticSource", "4.0.4.0").WithWindowsPowerShell(),

src/Accounts/Authentication.Test/TelemetryTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,10 @@ public void DataCollectionHandlesWriteErrors()
245245
AzureSession.Instance.DataStore = mock.Object;
246246
try
247247
{
248+
#pragma warning disable CS0436 // Type conflicts with imported type. ConfigKeys.cs is included in the referenced projects.
248249
Assert.True(AzureSession.Instance.TryGetComponent<IConfigManager>(nameof(IConfigManager), out var manager)
249250
&& manager.GetConfigValue<bool>(ConfigKeys.EnableDataCollection));
251+
#pragma warning restore CS0436 // Type conflicts with imported type
250252
}
251253
finally
252254
{

src/Accounts/Authentication/Authentication.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<PsModuleName>Accounts</PsModuleName>
55
</PropertyGroup>
6-
6+
77
<Import Project="$(MSBuildThisFileDirectory)..\..\Az.props" />
88

99
<PropertyGroup>
@@ -13,7 +13,8 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Azure.Identity" Version="1.6.1" />
16-
<PackageReference Include="Microsoft.Identity.Client" Version="4.46.2" />
16+
<PackageReference Include="Azure.Identity.BrokeredAuthentication" Version="1.0.0-beta.3" />
17+
<PackageReference Include="Microsoft.Identity.Client" Version="4.49.1" />
1718
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="2.23.0" />
1819
</ItemGroup>
1920

src/Accounts/Authentication/Authentication/AdalConfiguration.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ namespace Microsoft.Azure.Commands.Common.Authentication
2323
/// </summary>
2424
public class AdalConfiguration
2525
{
26-
//
27-
// These constants define the default values to use for AD authentication
28-
// against RDFE
29-
//
30-
public const string PowerShellClientId = "1950a258-227b-4e31-a9cf-717495945fc2";
31-
3226
public static readonly Uri PowerShellRedirectUri = new Uri("urn:ietf:wg:oauth:2.0:oob");
3327

3428
// ID for site to pass to enable EBD (email-based differentiation)
@@ -50,7 +44,7 @@ public class AdalConfiguration
5044

5145
public AdalConfiguration()
5246
{
53-
ClientId = PowerShellClientId;
47+
ClientId = Constants.PowerShellClientId;
5448
ClientRedirectUri = PowerShellRedirectUri;
5549
ValidateAuthority = true;
5650
AdEndpoint = string.Empty;

0 commit comments

Comments
 (0)