joshcorr / SecretManagement.Hashicorp.Vault.KV

A PowerShell SecretManagement extension for Hashicorp Vault Key Value Engine
MIT License
30 stars 10 forks source link

[BUG] A variable with name 'VaultToken' already exists. #35

Open alxandr-elvia opened 2 years ago

alxandr-elvia commented 2 years ago

Describe the bug With a vault-token in the configuration for the vault, all commands fail when trying to create a variable that already exist.

To Reproduce Steps to reproduce the behavior:

    # register vault
    [hashtable]$VaultParameters = @{
        VaultServer   = $Address
        VaultToken    = ($Token | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString)
        VaultAuthType = 'RenewToken'
    }

    Register-SecretVault -AllowClobber -ModuleName SecretManagement.Hashicorp.Vault.KV -Name $Name -VaultParameters $VaultParameters

  # test vault
  Get-SecretVault -Name $Name | Test-SecretVault

Expected behavior It should not crash.

Screenshots image

Desktop (please complete the following information):

PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Linux 5.16.11-arch1-1 #1 SMP PREEMPT Thu, 24 Feb 2022 02:18:20 +0000
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional context Add any other context about the problem here.

alxandr-elvia commented 2 years ago

Also, just setting the VaultToken doesn't work, as in Invoke-VaultToken, it get's deleted if TokenExpireTime is before now (which it is, as it defaults to year 1600).