Skip to content

Commit 55e17cb

Browse files
authored
Made the breaking change warnings about Get-AzAccessToken not appear when -AsSecureString is used. (#26929)
1 parent 33458b7 commit 55e17cb

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

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+
* Made the breaking change warnings about `Get-AzAccessToken` not appear when `-AsSecureString` is used.
2223
* Fixed an issue that cmdlets may report warnings of "KeyNotFoundException". #26624
2324
* Fixed an issue that the `-AppliesTo` parameter of `Update-AzConfig` does not work as expected.
2425
* Upgraded Azure.Core to 1.44.1 and Azure.Identity to 1.13.0.

src/Accounts/Accounts/Token/GetAzureRmAccessToken.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@
1818
using Microsoft.Azure.Commands.ResourceManager.Common;
1919
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
2020
using Microsoft.Azure.PowerShell.Authenticators;
21-
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
2221
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2322

2423
using System;
2524
using System.Linq;
2625
using System.Management.Automation;
27-
using System.Security;
2826
using System.Text.Json;
2927

3028
namespace Microsoft.Azure.Commands.Profile
3129
{
32-
[GenericBreakingChangeWithVersion("The Token property of the output type will be changed from String to SecureString. Add the [-AsSecureString] switch to avoid the impact of this upcoming breaking change.", "14.0.0", "4.0.0")]
30+
[SecureStringBreakingChange("The Token property of the output type will be changed from String to SecureString. Add the [-AsSecureString] switch to avoid the impact of this upcoming breaking change.", "14.0.0", "5.0.0")]
3331
[Cmdlet(VerbsCommon.Get, AzureRMConstants.AzureRMPrefix + "AccessToken", DefaultParameterSetName = KnownResourceNameParameterSet)]
3432
[OutputType(typeof(PSAccessToken), typeof(PSSecureAccessToken))]
3533
public class GetAzureRmAccessTokenCommand : AzureRMCmdlet
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.Profile
19+
{
20+
/// <summary>
21+
/// Attribute to mark a breaking change that is specific for SecureString.
22+
/// Only applies to cmdlets that do not already have the -AsSecureString parameter.
23+
/// </summary>
24+
internal class SecureStringBreakingChangeAttribute : GenericBreakingChangeWithVersionAttribute
25+
{
26+
public SecureStringBreakingChangeAttribute(string changeDescription, string changeVersion, string breakingChangeVersion) : base(changeDescription, changeVersion, breakingChangeVersion)
27+
{
28+
}
29+
30+
public override bool IsApplicableToInvocation(InvocationInfo invocation)
31+
{
32+
return !invocation.BoundParameters.ContainsKey(nameof(GetAzureRmAccessTokenCommand.AsSecureString));
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)