Skip to content

Commit

Permalink
Made the breaking change warnings about Get-AzAccessToken not appea…
Browse files Browse the repository at this point in the history
…r when `-AsSecureString` is used. (#26929)
  • Loading branch information
isra-fel authored Dec 25, 2024
1 parent 33458b7 commit 55e17cb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Accounts/Accounts/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Made the breaking change warnings about `Get-AzAccessToken` not appear when `-AsSecureString` is used.
* Fixed an issue that cmdlets may report warnings of "KeyNotFoundException". #26624
* Fixed an issue that the `-AppliesTo` parameter of `Update-AzConfig` does not work as expected.
* Upgraded Azure.Core to 1.44.1 and Azure.Identity to 1.13.0.
Expand Down
4 changes: 1 addition & 3 deletions src/Accounts/Accounts/Token/GetAzureRmAccessToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@
using Microsoft.Azure.Commands.ResourceManager.Common;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.PowerShell.Authenticators;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

using System;
using System.Linq;
using System.Management.Automation;
using System.Security;
using System.Text.Json;

namespace Microsoft.Azure.Commands.Profile
{
[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")]
[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")]
[Cmdlet(VerbsCommon.Get, AzureRMConstants.AzureRMPrefix + "AccessToken", DefaultParameterSetName = KnownResourceNameParameterSet)]
[OutputType(typeof(PSAccessToken), typeof(PSSecureAccessToken))]
public class GetAzureRmAccessTokenCommand : AzureRMCmdlet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Profile
{
/// <summary>
/// Attribute to mark a breaking change that is specific for SecureString.
/// Only applies to cmdlets that do not already have the -AsSecureString parameter.
/// </summary>
internal class SecureStringBreakingChangeAttribute : GenericBreakingChangeWithVersionAttribute
{
public SecureStringBreakingChangeAttribute(string changeDescription, string changeVersion, string breakingChangeVersion) : base(changeDescription, changeVersion, breakingChangeVersion)
{
}

public override bool IsApplicableToInvocation(InvocationInfo invocation)
{
return !invocation.BoundParameters.ContainsKey(nameof(GetAzureRmAccessTokenCommand.AsSecureString));
}
}
}

0 comments on commit 55e17cb

Please sign in to comment.