Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the breaking change warnings about Get-AzAccessToken not appear when -AsSecureString is used. #26929

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
}