Skip to content

Commit

Permalink
🩹 [Patch]: Support Token as a SecureString on `Connect-GitHubAcco…
Browse files Browse the repository at this point in the history
…unt` (#155)

## Description

- Support `Token` as a `SecureString` on `Connect-GitHubAccount`

## Type of change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [ ] 📖 [Docs]
- [ ] 🪲 [Fix]
- [x] 🩹 [Patch]
- [ ] ⚠️ [Security fix]
- [ ] 🚀 [Feature]
- [ ] 🌟 [Breaking change]

## Checklist

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
  • Loading branch information
MariusStorhaug authored Nov 10, 2024
1 parent 5a54835 commit f06a200
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/functions/public/Auth/Connect-GitHubAccount.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@
)]
[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'
[Parameter(
Mandatory,
ParameterSetName = 'Token'
)]
[string] $Token,
[object] $Token,

# The client ID for the GitHub App to use for authentication.
[Parameter(ParameterSetName = 'UAT')]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f06a200

Please sign in to comment.