Skip to content

Commit be89fc1

Browse files
authored
Az.accounts 2.1.2 (#13397)
* fix issue: the error message is unclear if browser is unavailable for Interactive scenario * fix issues: a. Token is not renewed after expiring for LRO; b. AccountId is not respected in MSI * code refactoring * remove unused code * fix typo * update version * update for 2.1.2 * update version to 2.1.2
1 parent 90dc114 commit be89fc1

File tree

123 files changed

+317
-234
lines changed

Some content is hidden

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

123 files changed

+317
-234
lines changed

src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
using System.Threading;
2020
using System.Threading.Tasks;
2121

22+
using Azure.Identity;
23+
2224
using Microsoft.Azure.Commands.Common.Authentication;
2325
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
2426
using Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core;
@@ -29,6 +31,7 @@
2931
using Microsoft.Azure.Commands.Profile.Properties;
3032
using Microsoft.Azure.Commands.ResourceManager.Common;
3133
using Microsoft.Azure.PowerShell.Authenticators;
34+
using Microsoft.Identity.Client;
3235
using Microsoft.WindowsAzure.Commands.Common;
3336
using Microsoft.WindowsAzure.Commands.Utilities.Common;
3437

@@ -398,12 +401,36 @@ public override void ExecuteCmdlet()
398401
}
399402

400403
HandleActions();
401-
var result = (PSAzureProfile) (task.ConfigureAwait(false).GetAwaiter().GetResult());
402-
WriteObject(result);
404+
405+
try
406+
{
407+
var result = (PSAzureProfile)(task.ConfigureAwait(false).GetAwaiter().GetResult());
408+
WriteObject(result);
409+
}
410+
catch (AuthenticationFailedException ex)
411+
{
412+
if(IsUnableToOpenWebPageError(ex))
413+
{
414+
WriteWarning(Resources.InteractiveAuthNotSupported);
415+
WriteDebug(ex.ToString());
416+
}
417+
else
418+
{
419+
WriteWarning(Resources.SuggestToUseDeviceCodeAuth);
420+
WriteDebug(ex.ToString());
421+
throw;
422+
}
423+
}
403424
});
404425
}
405426
}
406427

428+
private bool IsUnableToOpenWebPageError(AuthenticationFailedException exception)
429+
{
430+
return exception.InnerException is MsalClientException && ((MsalClientException)exception.InnerException)?.ErrorCode == MsalError.LinuxXdgOpen
431+
|| (exception.Message?.ToLower()?.Contains("unable to open a web page") ?? false);
432+
}
433+
407434
private ConcurrentQueue<Task> _tasks = new ConcurrentQueue<Task>();
408435

409436
private void HandleActions()

src/Accounts/Accounts/Az.Accounts.psd1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 10/23/2020
6+
# Generated on: 11/2/2020
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.1.0'
15+
ModuleVersion = '2.1.2'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = 'Core', 'Desktop'
@@ -143,8 +143,7 @@ PrivateData = @{
143143
# IconUri = ''
144144

145145
# ReleaseNotes of this module
146-
ReleaseNotes = '* [Breaking Change] Removed ''Get-AzProfile'' and ''Select-AzProfile''
147-
* Replaced Azure Directory Authentication Library with Microsoft Authentication Library(MSAL)'
146+
ReleaseNotes = '* Fixed one issue related to MSI'
148147

149148
# Prerelease string of this module
150149
# Prerelease = ''

src/Accounts/Accounts/ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
* Fixed an issue causing `Connect-AzAccount -KeyVaultAccessToken` not working [#13127]
2222
* Fixed null reference and method case insensitive in `Invoke-AzRestMethod`
2323

24+
## Version 2.1.2
25+
* Fixed one issue related to MSI
26+
27+
## Version 2.1.1
28+
* Fixed the issue that token is not renewed after expiring for LRO [#13367]
29+
* Fixed the issue that AccountId is not respected in MSI [#13376]
30+
* Fixed the issue that error message is unclear if browser is not avaialable for Interactive auth [#13340]
31+
2432
## Version 2.1.0
2533
* [Breaking Change] Removed `Get-AzProfile` and `Select-AzProfile`
2634
* Replaced Azure Directory Authentication Library with Microsoft Authentication Library(MSAL)

src/Accounts/Accounts/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
// You can specify all the values or you can default the Build and Revision Numbers
4444
// by using the '*' as shown below:
4545

46-
[assembly: AssemblyVersion("2.1.0")]
47-
[assembly: AssemblyFileVersion("2.1.0")]
46+
[assembly: AssemblyVersion("2.1.2")]
47+
[assembly: AssemblyFileVersion("2.1.2")]
4848
#if !SIGN
4949
[assembly: InternalsVisibleTo("Microsoft.Azure.PowerShell.Cmdlets.Accounts.Test")]
5050
#endif

src/Accounts/Accounts/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Accounts/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,10 @@
513513
<data name="SendFeedbackOpenLinkManually" xml:space="preserve">
514514
<value>Use a web browser to open the page {0}.</value>
515515
</data>
516+
<data name="InteractiveAuthNotSupported" xml:space="preserve">
517+
<value>Interactive authentication is not supported in this session, please run Connect-AzAccount using switch -DeviceCode.</value>
518+
</data>
519+
<data name="SuggestToUseDeviceCodeAuth" xml:space="preserve">
520+
<value>Please run 'Connect-AzAccount -DeviceCode' if browser is not supported in this session.</value>
521+
</data>
516522
</root>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ Accept wildcard characters: False
610610

611611
### -UseDeviceAuthentication
612612

613-
Use device code authentication instead of a browser control. This is the default authentication type
614-
for PowerShell version 6 and higher.
613+
Use device code authentication instead of a browser control.
615614

616615
```yaml
617616
Type: System.Management.Automation.SwitchParameter

src/Accounts/Authentication/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@
4343
// You can specify all the values or you can default the Build and Revision Numbers
4444
// by using the '*' as shown below:
4545
// [assembly: AssemblyVersion("1.0.*")]
46-
[assembly: AssemblyVersion("2.1.0")]
47-
[assembly: AssemblyFileVersion("2.1.0")]
46+
[assembly: AssemblyVersion("2.1.2")]
47+
[assembly: AssemblyFileVersion("2.1.2")]

src/Accounts/Authenticators/DeviceCodeAuthenticator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public override Task<IAccessToken> Authenticate(AuthenticationParameters paramet
5757
var authTask = codeCredential.AuthenticateAsync(requestContext, source.Token);
5858
return MsalAccessToken.GetAccessTokenAsync(
5959
authTask,
60-
() => codeCredential.GetTokenAsync(requestContext, source.Token),
60+
codeCredential,
61+
requestContext,
6162
source.Token);
6263
}
6364

src/Accounts/Authenticators/InteractiveUserAuthenticator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public override Task<IAccessToken> Authenticate(AuthenticationParameters paramet
7171

7272
return MsalAccessToken.GetAccessTokenAsync(
7373
authTask,
74-
() => browserCredential.GetTokenAsync(requestContext, source.Token),
74+
browserCredential,
75+
requestContext,
7576
source.Token);
7677
}
7778

0 commit comments

Comments
 (0)