Replace hardcoded cloud-to-scope mappings with static SSH auth scope and deprecate SshAuthScope parameter#29228
Replace hardcoded cloud-to-scope mappings with static SSH auth scope and deprecate SshAuthScope parameter#29228
Conversation
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Replace the CloudToScope dictionary mapping specific cloud names to cloud-specific scope URLs with a single static scope using the AAD SSH Login for Linux server app ID (ce6ff14a-7fdc-4685-bbe0-f6afdfcfa8e0). This enables SSH authentication across all clouds instead of only supporting AzureCloud, AzureChinaCloud, and AzureUSGovernment. The environment property AzureSshAuthScope still takes precedence when set, preserving backward compatibility. Similar to Azure CLI extensions PR #9465. Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
|
@copilot here are my comments: |
- Remove AzureSshAuthScope environment property lookup from SshCredentialFactory.cs, relying solely on static scope value - Remove unused using directives (AzPSKeyNotFoundException, etc.) - Update Set-AzEnvironment and Add-AzEnvironment help docs to mark -SshAuthScope parameter as deprecated - Update ChangeLog.md with deprecation notice Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
…64UrlHelper) Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
Done in a165a45. Changes made:
|
|
One last thing @copilot find the source code of the |
…zEnvironment cmdlet source Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
Updated the HelpMessage in both |
Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
… copilot/refactor-cloud-scope-mappings
|
/azp run azure-powershell - security-tools |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
This PR updates Azure PowerShell’s SSH certificate authentication to use a single, cross-cloud AAD app scope instead of per-cloud scope mappings, and deprecates the -SshAuthScope environment parameter accordingly.
Changes:
- Simplified
SshCredentialFactoryto always use a static SSH auth scope (ce6ff14a-7fdc-4685-bbe0-f6afdfcfa8e0/.default) and removed the cloud-to-scope mapping + environment property lookup. - Marked
-SshAuthScopeas deprecated in cmdlet parameter help metadata (Add-AzEnvironment,Set-AzEnvironment) and updated reference help markdown. - Added release notes entries describing the static scope change and the parameter deprecation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Accounts/Authentication/Factories/SshCredentialFactory.cs | Removes cloud/env-property scope resolution in favor of a single static .default scope. |
| src/Accounts/Accounts/Environment/SetAzureRMEnvironment.cs | Updates -SshAuthScope parameter help text to indicate deprecation. |
| src/Accounts/Accounts/Environment/AddAzureRMEnvironment.cs | Updates -SshAuthScope parameter help text to indicate deprecation. |
| src/Accounts/Accounts/help/Set-AzEnvironment.md | Updates -SshAuthScope reference help to indicate deprecation. |
| src/Accounts/Accounts/help/Add-AzEnvironment.md | Updates -SshAuthScope reference help to indicate deprecation. |
| src/Accounts/Accounts/ChangeLog.md | Adds Upcoming Release notes for the static scope behavior and deprecation. |
| * Replaced hardcoded cloud-to-scope mappings in SSH credential factory with a static scope, enabling SSH authentication across all clouds. | ||
| * Deprecated the `-SshAuthScope` parameter in `Set-AzEnvironment` and `Add-AzEnvironment`. The SSH authentication scope is now determined automatically. |
There was a problem hiding this comment.
These ChangeLog entries are fairly implementation-focused (e.g., “cloud-to-scope mappings in SSH credential factory”). Since the ChangeLog is user-facing, consider rephrasing in terms of user impact (e.g., SSH certificate auth now works across Azure clouds without configuring -SshAuthScope, and -SshAuthScope is deprecated).
| * Replaced hardcoded cloud-to-scope mappings in SSH credential factory with a static scope, enabling SSH authentication across all clouds. | |
| * Deprecated the `-SshAuthScope` parameter in `Set-AzEnvironment` and `Add-AzEnvironment`. The SSH authentication scope is now determined automatically. | |
| * Improved SSH (Secure Shell) certificate authentication for Az SSH cmdlets across all Azure clouds. | |
| - SSH certificate authentication now works across all Azure clouds without configuring the `-SshAuthScope` parameter. | |
| - The `-SshAuthScope` parameter in `Set-AzEnvironment` and `Add-AzEnvironment` is deprecated, and the SSH authentication scope is now determined automatically. |
| [Parameter(ParameterSetName = EnvironmentPropertiesParameterSet, Mandatory = false, ValueFromPipelineByPropertyName = true, | ||
| HelpMessage = "The scope for authentication when SSH to an Azure VM.")] | ||
| HelpMessage = "This parameter is deprecated and will be removed in a future release. The SSH authentication scope is now determined automatically and does not need to be configured.")] | ||
| public string SshAuthScope { get; set; } |
There was a problem hiding this comment.
-SshAuthScope is now documented as deprecated, but the cmdlet still persists the value into the environment (AzureSshAuthScope). Since the SSH credential flow no longer reads this endpoint, consider emitting a warning when the parameter is supplied (and/or ignoring it) to avoid users thinking it will affect SSH auth.
| public string SshAuthScope { get; set; } | |
| [Obsolete("This parameter is deprecated and is ignored. SSH authentication scope is determined automatically.")] | |
| public string SshAuthScope | |
| { | |
| get | |
| { | |
| // This parameter is deprecated and intentionally ignored. | |
| // Returning null ensures that any existing code paths that read this | |
| // property will not use a user supplied value. | |
| return null; | |
| } | |
| set | |
| { | |
| if (!string.IsNullOrEmpty(value)) | |
| { | |
| // Emit a warning so users know this parameter no longer affects SSH authentication. | |
| WriteWarning("The SshAuthScope parameter is deprecated and is ignored. SSH authentication scope is now determined automatically and does not need to be configured."); | |
| } | |
| } | |
| } |
| [Parameter(ParameterSetName = EnvironmentPropertiesParameterSet, Mandatory = false, ValueFromPipelineByPropertyName = true, | ||
| HelpMessage = "The scope for authentication when SSH to an Azure VM.")] | ||
| HelpMessage = "This parameter is deprecated and will be removed in a future release. The SSH authentication scope is now determined automatically and does not need to be configured.")] | ||
| public string SshAuthScope { get; set; } |
There was a problem hiding this comment.
-SshAuthScope is now documented as deprecated, but the cmdlet still persists the value into the environment (AzureSshAuthScope). Since the SSH credential flow no longer reads this endpoint, consider emitting a warning when the parameter is supplied (and/or ignoring it) to avoid users thinking it will affect SSH auth.
Port of Azure CLI extensions PR #9465. Replaces per-cloud scope URL mappings with a single app ID-based scope that works across all clouds, and deprecates the
SshAuthScopeenvironment property.Changes
SshCredentialFactory.cs: RemoveCloudToScopedictionary (which only covered AzureCloud, AzureChinaCloud, AzureUSGovernment) and theAzureSshAuthScopeenvironment property lookup. The SSH auth scope is now solely determined by the static valuece6ff14a-7fdc-4685-bbe0-f6afdfcfa8e0/.default, which works across all clouds.SetAzureRMEnvironment.csandAddAzureRMEnvironment.cs: Updated theSshAuthScopeparameter'sHelpMessagemetadata to indicate it is deprecated and will be removed in a future release.Set-AzEnvironment.mdandAdd-AzEnvironment.md: Updated the-SshAuthScopeparameter description to indicate it is deprecated and will be removed in a future release.ChangeLog.md: Added entries for the static scope change and the deprecation of-SshAuthScope.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.