Adding Service Principal Support to SSH Adjacent Services#29535
Open
DevanshG1 wants to merge 1 commit intoAzure:mainfrom
Open
Adding Service Principal Support to SSH Adjacent Services#29535DevanshG1 wants to merge 1 commit intoAzure:mainfrom
DevanshG1 wants to merge 1 commit intoAzure:mainfrom
Conversation
| Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables SSH certificate acquisition (for Microsoft Entra ID login) when the current Az context is authenticated as a Service Principal, extending the existing user-only flow. It updates the shared authentication factory to use MSAL confidential client flows, relaxes prior account-type restrictions in SSH/SFTP modules, and adds scenario tests plus changelog entries.
Changes:
- Updated
SshCredentialFactoryto acquire SSH-cert access tokens for ServicePrincipal accounts (confidential client) in addition to User accounts (public client). - Relaxed SSH/SFTP certificate generation error handling to allow Service Principal contexts (and to wrap additional exception types).
- Added SFTP scenario tests for factory interaction and updated module changelogs.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Ssh/Ssh/Common/SshBaseCmdlet.cs | Broadens exception handling to allow Service Principal flows by removing the user-only restriction path. |
| src/Ssh/Ssh/ChangeLog.md | Documents Service Principal support for SSH Entra ID certificate auth. |
| src/Sftp/Sftp/Common/FileUtils.cs | Broadens exception handling to allow Service Principal flows and standardizes wrapped errors. |
| src/Sftp/Sftp/CHANGELOG.md | Documents Service Principal support for SFTP Entra ID certificate auth. |
| src/Sftp/Sftp.Test/ScenarioTests/FileUtilsTests.cs | Adds scenario tests to validate Service Principal and user flows through the credential factory. |
| src/Accounts/Authentication/Properties/Resources.resx | Adds localized strings for unsupported account type and missing SP credentials. |
| src/Accounts/Authentication/Properties/Resources.Designer.cs | Generated resource accessors for new localized strings. |
| src/Accounts/Authentication/Factories/SshCredentialFactory.cs | Implements Service Principal SSH-cert acquisition via confidential client + authentication extension. |
| src/Accounts/Authentication/Authentication/TokenCache/PowerShellTokenCacheProvider.cs | Adds confidential client construction helpers for client secret/certificate flows. |
| src/Accounts/Accounts/ChangeLog.md | Documents the Accounts-side factory enhancement enabling SP automation scenarios. |
Files not reviewed (1)
- src/Accounts/Authentication/Properties/Resources.Designer.cs: Language not supported
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Security; |
Comment on lines
+137
to
+151
| if (certificate != null) | ||
| { | ||
| return tokenCacheProvider.CreateConfidentialClient(authority, tenantId, clientId, certificate); | ||
| } | ||
| } | ||
|
|
||
| // Try certificate path | ||
| string certificatePath = context.Account.GetProperty(AzureAccount.Property.CertificatePath); | ||
| if (!string.IsNullOrEmpty(certificatePath)) | ||
| { | ||
| SecureString certificatePassword = GetServicePrincipalSecureString(context, AzureAccount.Property.CertificatePassword); | ||
| X509Certificate2 certificate = certificatePassword != null | ||
| ? new X509Certificate2(certificatePath, certificatePassword) | ||
| : new X509Certificate2(certificatePath); | ||
| return tokenCacheProvider.CreateConfidentialClient(authority, tenantId, clientId, certificate); |
Collaborator
|
/azp run |
Contributor
|
Azure Pipelines successfully started running 3 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Mandatory Checklist
Please choose the target release of Azure PowerShell. (⚠️ Target release is a different concept from API readiness. Please click below links for details.)
Check this box to confirm: I have read the Submitting Changes section of
CONTRIBUTING.mdand reviewed the following information:ChangeLog.mdfile(s) appropriatelysrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.## Upcoming Releaseheader in the past tense.ChangeLog.mdif no new release is required, such as fixing test case only.