From f06a200110720480351a4cdf69de667223fc7617 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 10 Nov 2024 18:25:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Support=20`Token`=20a?= =?UTF-8?q?s=20a=20`SecureString`=20on=20`Connect-GitHubAccount`=20(#155)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description - Support `Token` as a `SecureString` on `Connect-GitHubAccount` ## Type of change - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas --- src/functions/public/Auth/Connect-GitHubAccount.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/functions/public/Auth/Connect-GitHubAccount.ps1 b/src/functions/public/Auth/Connect-GitHubAccount.ps1 index e10e673b..7694381d 100644 --- a/src/functions/public/Auth/Connect-GitHubAccount.ps1 +++ b/src/functions/public/Auth/Connect-GitHubAccount.ps1 @@ -78,7 +78,7 @@ )] [switch] $UseAccessToken, - # An access token to use for authentication. + # An access token to use for authentication. Can be both a string or a SecureString. # Supports both personal access tokens (PAT) and GitHub App installation access tokens (IAT). # Example: 'ghp_1234567890abcdef' # Example: 'ghs_1234567890abcdef' @@ -86,7 +86,7 @@ Mandatory, ParameterSetName = 'Token' )] - [string] $Token, + [object] $Token, # The client ID for the GitHub App to use for authentication. [Parameter(ParameterSetName = 'UAT')] @@ -133,6 +133,10 @@ [switch] $Silent ) try { + if ($Token -is [System.Security.SecureString]) { + $Token = ConvertFrom-SecureString $Token -AsPlainText + } + $HostName = $HostName -replace '^https?://' $ApiBaseUri = "https://api.$HostName" $authType = $PSCmdlet.ParameterSetName