Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum HashicorpVaultAuthTypes {
LDAP
userpass
Token
kerberos
}
class HashicorpVaultKV {
static [string] $VaultServer
Expand Down Expand Up @@ -109,6 +110,7 @@ function Invoke-VaultToken {
Retrieves Token based on Supported Credential
#>
process {
$additionalInvokeRestArguments = @{};
switch ([HashicorpVaultKV]::VaultAuthType) {
"AppRole" {
$Credential = Get-Credential -Message "Please Enter Role-Id and Secret-Id"
Expand All @@ -129,6 +131,11 @@ function Invoke-VaultToken {
$UserPassword = "{`"password`":`"$($Credential.GetNetworkCredential().Password)`"}"
continue
}
"kerberos" {
$UserLogin = "$([HashicorpVaultKV]::VaultServer)/$([HashicorpVaultKV]::VaultAPIVersion)/auth/kerberos/login"
$additionalInvokeRestArguments.Add('UseDefaultCredentials', $true);
continue
}
"Token" {
[HashicorpVaultKV]::VaultToken = (Get-Credential -UserName Token -Message "Please Enter the token").Password
break
Expand All @@ -146,7 +153,7 @@ function Invoke-VaultToken {
}
try {
if ([HashicorpVaultKV]::VaultAuthType -ne 'Token') {
$auth = (Invoke-RestMethod -Method POST -Uri $UserLogin -Body $UserPassword)
$auth = (Invoke-RestMethod -Method POST -Uri $UserLogin -Body $UserPassword @additionalInvokeRestArguments)
[HashicorpVaultKV]::VaultToken = $auth.auth.client_token | ConvertTo-SecureString -AsPlainText -Force
}
#Register an Event to prompt whent he token is expiring
Expand Down