-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for keymgmt secrets engine
- Loading branch information
Showing
28 changed files
with
285 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// <autogenerated /> | ||
using System; | ||
using System.Reflection; | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")] | ||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETStandard,Version=v1.3", FrameworkDisplayName = "")] |
24 changes: 24 additions & 0 deletions
24
src/VaultSharp/V1/SecretsEngines/Enterprise/EnterpriseProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using VaultSharp.Core; | ||
using VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement; | ||
using VaultSharp.V1.SecretsEngines.Enterprise.KMIP; | ||
using VaultSharp.V1.SecretsEngines.Enterprise.Transform; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise | ||
{ | ||
/// <summary> | ||
/// Enterprise Secrets Engines | ||
/// </summary> | ||
internal class EnterpriseProvider : IEnterprise | ||
{ | ||
public EnterpriseProvider(Polymath polymath) | ||
{ | ||
KeyManagement = new KeyManagementSecretsEngineProvider(polymath); | ||
KMIP = new KMIPSecretsEngineProvider(polymath); | ||
Transform = new TransformSecretsEngineProvider(polymath); | ||
} | ||
|
||
public IKeyManagementSecretsEngine KeyManagement { get; } | ||
public IKMIPSecretsEngine KMIP { get; } | ||
public ITransformSecretsEngine Transform { get; } | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/VaultSharp/V1/SecretsEngines/Enterprise/IEnterprise.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement; | ||
using VaultSharp.V1.SecretsEngines.Enterprise.KMIP; | ||
using VaultSharp.V1.SecretsEngines.Enterprise.Transform; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise | ||
{ | ||
/// <summary> | ||
/// Enterprise Secrets Engines | ||
/// </summary> | ||
public interface IEnterprise | ||
{ | ||
/// <summary> | ||
/// The KeyManagement Secrets Engine. | ||
/// </summary> | ||
IKeyManagementSecretsEngine KeyManagement { get; } | ||
|
||
/// <summary> | ||
/// The KMIP Secrets Engine. | ||
/// </summary> | ||
IKMIPSecretsEngine KMIP { get; } | ||
|
||
/// <summary> | ||
/// The Transform Secrets Engine. | ||
/// </summary> | ||
ITransformSecretsEngine Transform { get; } | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../SecretsEngines/KMIP/CertificateFormat.cs → ...ines/Enterprise/KMIP/CertificateFormat.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...SecretsEngines/KMIP/IKMIPSecretsEngine.cs → ...nes/Enterprise/KMIP/IKMIPSecretsEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...V1/SecretsEngines/KMIP/KMIPCredentials.cs → ...ngines/Enterprise/KMIP/KMIPCredentials.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/VaultSharp/V1/SecretsEngines/Enterprise/KeyManagement/IKeyManagementSecretsEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System.Threading.Tasks; | ||
using VaultSharp.V1.Commons; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement | ||
{ | ||
/// <summary> | ||
/// The KeyManagement Secrets Engine. | ||
/// </summary> | ||
public interface IKeyManagementSecretsEngine | ||
{ | ||
/// <summary> | ||
/// Reads information about a named key. | ||
/// The keys object will hold information regarding each key version. | ||
/// Different information will be returned depending on the key type. | ||
/// For example, an asymmetric key will return its public key in a standard format for the type. | ||
/// </summary> | ||
/// <param name="keyName"><para>[required]</para> | ||
/// Specifies the name of the key to read. | ||
/// </param> | ||
/// <param name="mountPoint"><para>[optional]</para> | ||
/// The mount point for the backend. Defaults to <see cref="SecretsEngineDefaultPaths.KeyManagement" /> | ||
/// Provide a value only if you have customized the mount point.</param> | ||
/// <param name="wrapTimeToLive"> | ||
/// <para>[optional]</para> | ||
/// The TTL for the token and can be either an integer number of seconds or a string duration of seconds. | ||
/// </param> | ||
/// <returns>Key Info.</returns> | ||
Task<Secret<KeyManagementKey>> ReadKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.KeyManagement, string wrapTimeToLive = null); | ||
|
||
/// <summary> | ||
/// Reads information about a key that's been distributed to a KMS provider. | ||
/// </summary> | ||
/// <param name="kmsName"><para>[required]</para> | ||
/// Specifies the name of the KMS provider. | ||
/// </param> | ||
/// <param name="keyName"><para>[required]</para> | ||
/// Specifies the name of the key to read. | ||
/// </param> | ||
/// <param name="mountPoint"><para>[optional]</para> | ||
/// The mount point for the backend. Defaults to <see cref="SecretsEngineDefaultPaths.KeyManagement" /> | ||
/// Provide a value only if you have customized the mount point.</param> | ||
/// <param name="wrapTimeToLive"> | ||
/// <para>[optional]</para> | ||
/// The TTL for the token and can be either an integer number of seconds or a string duration of seconds. | ||
/// </param> | ||
/// <returns>Key Info.</returns> | ||
Task<Secret<KeyManagementKMSKey>> ReadKeyInKMSAsync(string kmsName, string keyName, string mountPoint = SecretsEngineDefaultPaths.KeyManagement, string wrapTimeToLive = null); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/VaultSharp/V1/SecretsEngines/Enterprise/KeyManagement/KeyManagementKMSKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement | ||
{ | ||
/// <summary> | ||
/// Key in KMS | ||
/// </summary> | ||
public class KeyManagementKMSKey | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("protection")] | ||
public string Protection { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("purpose")] | ||
public string Purpose { get; set; } | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/VaultSharp/V1/SecretsEngines/Enterprise/KeyManagement/KeyManagementKey.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement | ||
{ | ||
/// <summary> | ||
/// The KeyMgmt key | ||
/// </summary> | ||
public class KeyManagementKey | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("deletion_allowed")] | ||
public bool DeletionAllowed { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("keys")] | ||
public Dictionary<string, Dictionary<string, object>> Keys; | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("latest_version")] | ||
public int LatestVersion { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("min_enabled_version")] | ||
public int MinimumEnabledVersion { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
[JsonProperty("type")] | ||
public string Type { get; set; } | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...ultSharp/V1/SecretsEngines/Enterprise/KeyManagement/KeyManagementSecretsEngineProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using VaultSharp.Core; | ||
using VaultSharp.V1.Commons; | ||
|
||
namespace VaultSharp.V1.SecretsEngines.Enterprise.KeyManagement | ||
{ | ||
internal class KeyManagementSecretsEngineProvider : IKeyManagementSecretsEngine | ||
{ | ||
private readonly Polymath _polymath; | ||
|
||
public KeyManagementSecretsEngineProvider(Polymath polymath) | ||
{ | ||
_polymath = polymath; | ||
} | ||
|
||
public async Task<Secret<KeyManagementKey>> ReadKeyAsync(string keyName, string mountPoint = SecretsEngineDefaultPaths.KeyManagement, string wrapTimeToLive = null) | ||
{ | ||
Checker.NotNull(mountPoint, "mountPoint"); | ||
Checker.NotNull(keyName, "keyName"); | ||
|
||
return await _polymath.MakeVaultApiRequest<Secret<KeyManagementKey>>("v1/" + mountPoint.Trim('/') + "/key/" + keyName.Trim('/'), HttpMethod.Get, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); | ||
} | ||
|
||
public async Task<Secret<KeyManagementKMSKey>> ReadKeyInKMSAsync(string kmsName, string keyName, string mountPoint = SecretsEngineDefaultPaths.KeyManagement, string wrapTimeToLive = null) | ||
{ | ||
Checker.NotNull(mountPoint, "mountPoint"); | ||
Checker.NotNull(kmsName, "kmsName"); | ||
Checker.NotNull(keyName, "keyName"); | ||
|
||
return await _polymath.MakeVaultApiRequest<Secret<KeyManagementKMSKey>>("v1/" + mountPoint.Trim('/') + "/kms/" + kmsName.Trim('/') + "/key/" + keyName.Trim('/'), HttpMethod.Get, wrapTimeToLive: wrapTimeToLive).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...Engines/Transform/DecodeRequestOptions.cs → ...erprise/Transform/DecodeRequestOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...1/SecretsEngines/Transform/DecodedItem.cs → ...gines/Enterprise/Transform/DecodedItem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cretsEngines/Transform/DecodedResponse.cs → ...s/Enterprise/Transform/DecodedResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.