-
Notifications
You must be signed in to change notification settings - Fork 5
🚀 [Feature]: Adding functionality to sign JWTs via Key Vault Keys #481
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
base: main
Are you sure you want to change the base?
Conversation
…WTSignature` functions; update `Update-GitHubAppJWT` to use local signing method
…r JWT signing functions and update authentication methods in `Connect-GitHubAccount`
…t for enhanced security
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request introduces Azure Key Vault integration for GitHub App JWT signing, enabling secure storage and usage of private keys through Azure Key Vault as an alternative to local private key files. The changes enhance security by eliminating the need to store sensitive private keys locally while maintaining backward compatibility with existing private key authentication.
- Adds support for Azure Key Vault key references in GitHub App authentication flows
- Refactors JWT signing functionality to support both local private keys and Key Vault-based signing
- Introduces new utility functions to validate Azure CLI and Azure PowerShell authentication states
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
File | Description |
---|---|
Connect-GitHubAccount.ps1 | Enhanced to support Key Vault key references with new parameter sets and validation |
Test-GitHubAzureCLI.ps1 | New utility function to verify Azure CLI installation and authentication status |
Test-GitHubAzPowerShell.ps1 | New utility function to verify Azure PowerShell module availability and authentication |
Update-GitHubAppJWT.ps1 | Modified to conditionally use either local or Key Vault JWT signing based on context |
New-GitHubUnsignedJWT.ps1 | Refactored to use new GitHubJWTComponent class for base64 URL encoding |
Add-GitHubLocalJWTSignature.ps1 | Renamed from Add-GitHubJWTSignature and updated to return secure string |
Add-GitHubKeyVaultJWTSignature.ps1 | New function implementing Key Vault-based JWT signing with Azure authentication |
GitHubJWTComponent.ps1 | New utility class centralizing base64 URL encoding logic for JWT operations |
GitHubAppContext.ps1 | Extended to include KeyVaultKeyReference property for Key Vault authentication |
README.md | Updated documentation with Key Vault authentication examples and prerequisites |
src/functions/private/Apps/GitHub Apps/New-GitHubUnsignedJWT.ps1
Outdated
Show resolved
Hide resolved
src/functions/private/Apps/GitHub Apps/New-GitHubUnsignedJWT.ps1
Outdated
Show resolved
Hide resolved
src/functions/private/Apps/GitHub Apps/New-GitHubUnsignedJWT.ps1
Outdated
Show resolved
Hide resolved
src/functions/private/Apps/GitHub Apps/New-GitHubUnsignedJWT.ps1
Outdated
Show resolved
Hide resolved
src/functions/private/Apps/GitHub Apps/Add-GitHubKeyVaultJWTSignature.ps1
Show resolved
Hide resolved
src/functions/private/Apps/GitHub Apps/Add-GitHubKeyVaultJWTSignature.ps1
Show resolved
Hide resolved
…ing GitHub App keys and signing JWTs
…remove mandatory requirement for GitHub App installation loading
… in `Update-GitHubAppJWT` and adding `Test-GitHubJWTRefreshRequired` function for refresh validation
…T` and `Update-GitHubUserAccessToken` to use hyphens instead of slashes for improved compatibility
…ired` to use `JwtTimeTolerance` instead of `JwtRefreshThreshold` for improved accuracy
- Created TEMPLATE.ps1 for Pester tests with default configurations. - Added Teams.Tests.ps1 to test GitHub Teams API functionalities including team creation, retrieval, updating, and deletion. - Introduced Users.Tests.ps1 to validate user-related API calls such as user retrieval and updates. - Implemented Variables.Tests.ps1 to cover GitHub variable management including setting, updating, and removing variables for users, organizations, and repositories.
…matting context display for better readability
…ed` and improve error handling in `Test-GitHubAccessTokenRefreshRequired`
- Created TEMPLATE.ps1 for structuring Pester tests with authentication cases. - Added Teams.Tests.ps1 to test GitHub Teams API functionalities, including team creation, retrieval, updating, and deletion. - Introduced Users.Tests.ps1 to validate user-related API calls, including user retrieval and updates. - Implemented Variables.Tests.ps1 to test GitHub variable management, covering organization and repository scopes, variable creation, updates, and deletions.
…r JWT and access token refresh processes
Description
This pull request introduces support for signing GitHub App JSON Web Tokens (JWTs) using Azure Key Vault in addition to local RSA private keys. It also refactors and enhances existing JWT-related functionality to improve maintainability and clarity. The most significant changes include the addition of Azure Key Vault integration, refactoring of JWT signing methods, and updates to related utility functions.
Improvements to Authentication Logic
Connect-GitHubAccount
to support both private key and Azure Key Vault-based authentication for GitHub Apps, introducing new parameter sets and validation forKeyVaultKeyReference
.Azure Key Vault Integration
KeyVaultKeyReference
property to theGitHubAppContext
class for specifying Azure Key Vault keys as an alternative to local private keys.Add-GitHubKeyVaultJWTSignature
function to sign JWTs using Azure Key Vault keys, supporting both Azure CLI and Az PowerShell authentication.Test-GitHubAzureCLI
andTest-GitHubAzPowerShell
to check for Azure CLI and Az PowerShell module installation and authentication.Refactoring of JWT Signing
Add-GitHubJWTSignature
toAdd-GitHubLocalJWTSignature
for clarity and updated it to use the newGitHubJWTComponent
helper for base64 URL encoding.Update-GitHubAppJWT
to conditionally use eitherAdd-GitHubLocalJWTSignature
orAdd-GitHubKeyVaultJWTSignature
based on the presence ofPrivateKey
orKeyVaultKeyReference
in the context.Enhancements to JWT Utility Functions
GitHubJWTComponent
class to centralize base64 URL encoding logic and simplify JWT creation.New-GitHubUnsignedJWT
to useGitHubJWTComponent
for encoding JWT headers and payloads.Type of change
Checklist