mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-08 04:57:12 +00:00
fix: take the API token as a SecureString and stop exposing session credentials (#240)
Connect-PveServer -ApiToken was a plain string, so the token landed verbatim in PSReadLine history and any transcript, and PveSession published ApiToken, Ticket and CsrfToken as public getters, so Format-List *, ConvertTo-Json and Export-Clixml of a session printed them. The parameter is now a SecureString, extracted at the cmdlet boundary with the Marshal/ZeroFree pattern ADR 0002 established for passwords. A plain string still binds for one minor release through an argument transformation, and the cmdlet warns that the string form goes away in the next major; the marker lives in a ConditionalWeakTable keyed on the converted instance, so an abandoned binding neither retains the secret nor mislabels a later call. The three session getters become internal. PveHttpClient is in the same assembly and the xUnit project already has InternalsVisibleTo, so the header construction and its tests are unchanged. Refs ADR 0028, issue #147. Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8d955a0ea8
commit
c8a7e809bb
@@ -64,8 +64,9 @@ Import-Module PSProxmoxVE
|
||||
$cred = Get-Credential -UserName 'root@pam'
|
||||
Connect-PveServer -Server 'pve.example.com' -Credential $cred -SkipCertificateCheck
|
||||
|
||||
# Using API token
|
||||
Connect-PveServer -Server 'pve.example.com' -ApiToken 'root@pam!mytoken=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
# Using API token (SecureString)
|
||||
$token = Read-Host -AsSecureString -Prompt 'API token (root@pam!mytoken=...)'
|
||||
Connect-PveServer -Server 'pve.example.com' -ApiToken $token
|
||||
|
||||
# Verify connection
|
||||
Test-PveConnection -Detailed
|
||||
@@ -167,7 +168,9 @@ API tokens provide persistent, non-expiring authentication. They are the recomme
|
||||
4. Copy the token value — it is shown only once
|
||||
|
||||
```powershell
|
||||
Connect-PveServer -Server 'pve.example.com' -ApiToken 'root@pam!automation=12345678-abcd-efgh-ijkl-123456789012'
|
||||
# Read-Host keeps the token out of shell history and transcripts.
|
||||
$token = Read-Host -AsSecureString -Prompt 'API token (root@pam!automation=...)'
|
||||
Connect-PveServer -Server 'pve.example.com' -ApiToken $token
|
||||
```
|
||||
|
||||
## Multi-Cluster Usage
|
||||
|
||||
Reference in New Issue
Block a user