Skip to content

Commit

Permalink
rekey backup apis - get backup and delete
Browse files Browse the repository at this point in the history
supports the api equivalent of hashicorp/vault#907
  • Loading branch information
rajanadar committed Aug 29, 2016
1 parent d09c855 commit 9186292
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/VaultSharp/Backends/System/Models/RekeyBackupInfo.cs
@@ -0,0 +1,29 @@
using System.Collections.Generic;
using Newtonsoft.Json;

namespace VaultSharp.Backends.System.Models
{
/// <summary>
/// Represents the Rekey backup information.
/// </summary>
public class RekeyBackupInfo
{
/// <summary>
/// Gets or sets the nonce for the current rekey operation..
/// </summary>
/// <value>
/// The nonce.
/// </value>
[JsonProperty("nonce")]
public string Nonce { get; set; }

/// <summary>
/// Gets or sets the map of PGP key fingerprint to hex-encoded PGP-encrypted key.
/// </summary>
/// <value>
/// The map of PGP key fingerprint to hex-encoded PGP-encrypted key.
/// </value>
[JsonProperty("keys")]
public Dictionary<string, string> PGPFingerprintToEncryptedKeyMap { get; set; }
}
}
14 changes: 14 additions & 0 deletions src/VaultSharp/IVaultClient.cs
Expand Up @@ -423,6 +423,20 @@ public interface IVaultClient
/// </returns>
Task CancelRekeyAsync();

/// <summary>
/// Gets the the backup copy of PGP-encrypted unseal keys.
/// The returned value is the nonce of the rekey operation and a map of PGP key
/// fingerprint to hex-encoded PGP-encrypted key.
/// </summary>
/// <returns>The rekey backup info.</returns>
Task<RekeyBackupInfo> GetRekeyBackupKeysAsync();

/// <summary>
/// Deletes the backup copy of PGP-encrypted unseal keys.
/// </summary>
/// <returns>The task.</returns>
Task DeleteRekeyBackupKeysAsync();

/// <summary>
/// Continues the rekey process. Enter a single master key share to progress the rekey of the Vault.
/// If the threshold number of master key shares is reached, Vault will complete the rekey.
Expand Down
11 changes: 11 additions & 0 deletions src/VaultSharp/VaultClient.cs
Expand Up @@ -389,6 +389,17 @@ public async Task CancelRekeyAsync()
await MakeVaultApiRequest("sys/rekey/init", HttpMethod.Delete).ConfigureAwait(continueOnCapturedContext: _continueAsyncTasksOnCapturedContext);
}

public async Task<RekeyBackupInfo> GetRekeyBackupKeysAsync()
{
var rekeyBackupInfo = await MakeVaultApiRequest<RekeyBackupInfo>("sys/rekey/backup", HttpMethod.Get).ConfigureAwait(continueOnCapturedContext: _continueAsyncTasksOnCapturedContext);
return rekeyBackupInfo;
}

public async Task DeleteRekeyBackupKeysAsync()
{
await MakeVaultApiRequest("sys/rekey/backup", HttpMethod.Delete).ConfigureAwait(continueOnCapturedContext: _continueAsyncTasksOnCapturedContext);
}

public async Task<RekeyProgress> ContinueRekeyAsync(string masterShareKey, string rekeyNonce)
{
Checker.NotNull(masterShareKey, "masterShareKey");
Expand Down
1 change: 1 addition & 0 deletions src/VaultSharp/VaultSharp.csproj
Expand Up @@ -104,6 +104,7 @@
<Compile Include="Backends\Secret\Models\PKI\RawCertificateSigningRequestData.cs" />
<Compile Include="Backends\Secret\Models\PKI\CertificateEndpointData.cs" />
<Compile Include="Backends\Secret\Models\PKI\ExpiryData.cs" />
<Compile Include="Backends\System\Models\RekeyBackupInfo.cs" />
<Compile Include="Infrastructure\JsonConverters\SSHCredentialsJsonConverter.cs" />
<Compile Include="Infrastructure\JsonConverters\SSHRoleDefinitionJsonConverter.cs" />
<Compile Include="Infrastructure\JsonConverters\AuthenticationBackendTypeJsonConverter.cs" />
Expand Down

0 comments on commit 9186292

Please sign in to comment.