diff --git a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.Extension/SecretManagement.Keeper.Extension.psd1 b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.Extension/SecretManagement.Keeper.Extension.psd1
index b469eb72..5aaf1f53 100644
--- a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.Extension/SecretManagement.Keeper.Extension.psd1
+++ b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.Extension/SecretManagement.Keeper.Extension.psd1
@@ -1,5 +1,5 @@
@{
- ModuleVersion = '16.0.5'
+ ModuleVersion = '16.2.0'
RootModule = 'SecretManagement.Keeper.Extension.psm1'
RequiredAssemblies = '../SecretManagement.Keeper.dll'
CompatiblePSEditions = @('Core')
diff --git a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj
index df45d36e..ec8c79c2 100644
--- a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj
+++ b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.csproj
@@ -4,8 +4,8 @@
netstandard2.0
SecretManagement.Keeper
true
- 16.0.5
- 16.0.5
+ 16.2.0
+ 16.2.0
diff --git a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psd1 b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psd1
index 4f9df8ce..05d112da 100644
--- a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psd1
+++ b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psd1
@@ -1,5 +1,5 @@
@{
- ModuleVersion = '16.0.5'
+ ModuleVersion = '16.2.0'
CompatiblePSEditions = @('Core')
GUID = '20ab89cb-f0dd-4e8e-b276-f3a7708c1eb2'
Author = 'Sergey Aldoukhov'
diff --git a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psm1 b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psm1
index ecb3c9ab..3685291c 100644
--- a/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psm1
+++ b/sdk/dotNet/SecretManagement.Keeper/SecretManagement.Keeper.psm1
@@ -1,12 +1,18 @@
function Register-KeeperVault {
- [CmdletBinding()]
+ [CmdletBinding(DefaultParameterSetName = 'Token')]
param (
[Parameter(Mandatory = $true)]
[string] $Name,
- [Parameter(Mandatory = $true)]
+ [Parameter(Mandatory = $true, ParameterSetName = 'Token')]
[string] $OneTimeToken,
+ [Parameter(Mandatory = $true, ParameterSetName = 'Config')]
+ [string] $Config,
[string] $LocalVaultName
)
+ if ($PSVersionTable.PSVersion.Major -lt 6) {
+ Write-Error "Keeper Secrets Manager: this version of Powershell ($($PSVersionTable.PSVersion.ToString())) is not supported"
+ return
+ }
$vaults = Microsoft.Powershell.SecretManagement\Get-SecretVault
if ($LocalVaultName) {
$localVaultModuleName = $vaults.Where( { $_.Name -eq $LocalVaultName } ) | Select-Object -ExpandProperty ModuleName
@@ -26,7 +32,14 @@ function Register-KeeperVault {
$configSecretName = 'KeeperVault.' + $Name
Write-Host "Storing Keeper Vault config $($configSecretName) in $($localVaultModuleName) Vault named $($LocalVaultName)"
$moduleInstance = Import-Module -Name $localVaultModuleName -PassThru -ErrorAction Stop
- $result = [SecretManagement.Keeper.Client]::GetVaultConfig($OneTimeToken).GetAwaiter().GetResult()
+ switch ($PSCmdlet.ParameterSetName) {
+ 'Token' {
+ $result = [SecretManagement.Keeper.Client]::GetVaultConfigFromToken($OneTimeToken).GetAwaiter().GetResult()
+ }
+ 'Config' {
+ $result = [SecretManagement.Keeper.Client]::GetVaultConfigFromConfigString($Config).GetAwaiter().GetResult()
+ }
+ }
if ($result.IsFailure) {
Write-Error $result.ErrorMessage
return
diff --git a/sdk/dotNet/SecretManagement.Keeper/src/SecretManagement.cs b/sdk/dotNet/SecretManagement.Keeper/src/SecretManagement.cs
index 23e05f09..6f183b98 100644
--- a/sdk/dotNet/SecretManagement.Keeper/src/SecretManagement.cs
+++ b/sdk/dotNet/SecretManagement.Keeper/src/SecretManagement.cs
@@ -13,10 +13,25 @@ namespace SecretManagement.Keeper
{
public static class Client
{
- public static async Task GetVaultConfig(string oneTimeToken)
+ public static async Task GetVaultConfigFromToken(string oneTimeToken)
{
var storage = new InMemoryStorage();
- SecretsManagerClient.InitializeStorage(storage, oneTimeToken, "keepersecurity.com");
+ SecretsManagerClient.InitializeStorage(storage, oneTimeToken);
+ try
+ {
+ await SecretsManagerClient.GetSecrets(new SecretsManagerOptions(storage));
+ }
+ catch (Exception e)
+ {
+ return KeeperResult.Error(e.Message);
+ }
+
+ return KeeperResult.Ok(storage.AsHashTable());
+ }
+
+ public static async Task GetVaultConfigFromConfigString(string config)
+ {
+ var storage = new InMemoryStorage(config);
try
{
await SecretsManagerClient.GetSecrets(new SecretsManagerOptions(storage));
@@ -73,6 +88,9 @@ public static async Task