Skip to content

🚀[Feature]: Add functions to revoke tokens + remove some functions #432

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

Merged
merged 14 commits into from
Jul 1, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 21, 2025

This pull request introduces new functionality for revoking GitHub access tokens, enhances the Disconnect-GitHubAccount command to revoke tokens, and refactors or removes outdated examples and tests. These changes improve security and streamline token management.

Hiding some functions that were public previously

  • New-GitHubAppInstallationAccessToken
  • Get-GitHubAppJSONWebToken

New Features for Token Revocation

  • Added Revoke-GitHubAppInstallationAccessToken (private) function to revoke installation access tokens for GitHub Apps. This invalidates tokens and ensures they cannot be reused.
  • Introduced Revoke-GitHubAccessToken (public) function to revoke a list of exposed or unused credentials. Supports batch processing for up to 1000 tokens per request.

Enhancements to Existing Commands

  • Updated Disconnect-GitHubAccount to revoke access tokens during disconnection, improving security by preventing token reuse for Installation Access Tokens.

Refactoring and Cleanup

  • Removed outdated examples from CallingAPIs.ps1 related to JWT and installation access tokens.
  • Refactored tests in Apps.Tests.ps1 by removing redundant JWT and installation token tests, and added a test to verify that revoked tokens fail API calls.

…cation

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] 🚀[Feature]: Add function to revoke tokens Add Revoke-GitHubToken function for OAuth and installation token revocation Jun 21, 2025
@Copilot Copilot AI requested a review from MariusStorhaug June 21, 2025 13:37
Copilot finished work on behalf of MariusStorhaug June 21, 2025 13:37
@MariusStorhaug
Copy link
Member

You are missing the version that I wanted you to add:

curl -L \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/credentials/revoke \
  -d '{"credentials":["ghp_1234567890abcdef1234567890abcdef12345678","ghp_abcdef1234567890abcdef1234567890abcdef12"]}'

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 21, 2025

You are missing the version that I wanted you to add:

...

I've added support for the bulk credentials revocation endpoint using POST /credentials/revoke that can revoke multiple tokens at once. The function now has three parameter sets: OAuth, Installation, and Credentials. The new parameter accepts an array of credentials and uses the endpoint you specified. Commit 2e2184d addresses this.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.powershellgallery.com
    • Triggering command: pwsh -Command Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser (dns block)
    • Triggering command: pwsh -Command Get-PSRepository (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of MariusStorhaug June 21, 2025 14:26
Copilot AI and others added 2 commits June 21, 2025 14:42
…ate functions

Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Copilot finished work on behalf of MariusStorhaug June 21, 2025 14:46
@Copilot Copilot AI requested a review from MariusStorhaug June 21, 2025 14:46
…tion and streamline token revocation in `Disconnect-GitHubAccount` and `Revoke-GitHubAccessToken`
@MariusStorhaug MariusStorhaug marked this pull request as ready for review June 30, 2025 17:20
@MariusStorhaug MariusStorhaug requested a review from a team as a code owner June 30, 2025 17:20
@MariusStorhaug MariusStorhaug changed the title Add Revoke-GitHubToken function for OAuth and installation token revocation 🩹[Patch]: Add functions to revoke tokens Jul 1, 2025
@MariusStorhaug MariusStorhaug changed the title 🩹[Patch]: Add functions to revoke tokens 🚀[Feature]: Add functions to revoke tokens + remove some functions Jul 1, 2025
@MariusStorhaug MariusStorhaug merged commit a2e49c2 into main Jul 1, 2025
11 checks passed
@MariusStorhaug MariusStorhaug deleted the copilot/fix-414 branch July 1, 2025 09:00
@github-project-automation github-project-automation bot moved this from Todo to Done in GitHub PowerShell Module Jul 1, 2025
Copy link
Contributor

github-actions bot commented Jul 1, 2025

Module GitHub - 0.33.0 published to the PowerShell Gallery.

Copy link
Contributor

github-actions bot commented Jul 1, 2025

GitHub release for GitHub v0.33.0 has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

🚀[Feature]: Add function to revoke tokens
2 participants