Skip to content

Commit

Permalink
health status & backendconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
rajanadar committed Sep 14, 2024
1 parent b62dbba commit 4d4449b
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 74 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

## 1.17.5 (TBD)

**BREAKING CHANGES:**

* ```NewBackendConfig``` class is removed and instead ```BackendConfig``` class has been enhanced.

**IMROVEMENTS:**

* [GH-309](https://github.com/rajanadar/VaultSharp/issues/309) identity/oidc/key: create, read, update and delete apis.
Expand All @@ -14,6 +18,7 @@
* [GH-334](https://github.com/rajanadar/VaultSharp/issues/334) kv2/metadata: `ReadSecretPathsAsync` allows empty path value to list all secrets on the `mountPoint`
* [GH-342](https://github.com/rajanadar/VaultSharp/issues/342) /sys/policies/password/:name/generate password generation api.
* [GH-317](https://github.com/rajanadar/VaultSharp/issues/317) PKI: Read Default Issuer Certificate Chain API.
* Health Status now adds the new fields ```enterprise```, ```echo_duration_ms```, ```clock_skew_ms``` & ```replication_primary_canary_age_ms```

## 1.13.0.1 (April 03, 2023)

Expand Down
31 changes: 0 additions & 31 deletions next.txt
Original file line number Diff line number Diff line change
@@ -1,31 +0,0 @@

1.
HealthStatus
======================
From Vault Server: 501-NotImplemented
{"initialized":false,"sealed":true,"standby":true,"performance_standby":false,"replication_performance_mode":"unknown","replication_dr_mode":"unknown","server_time_utc":1726250022,"version":"1.17.5","enterprise":false,"echo_duration_ms":0,"clock_skew_ms":0,"replication_primary_canary_age_ms":0}

{"initialized":false,"sealed":true,"standby":true,"performance_standby":false,"replication_performance_mode":"unknown","replication_dr_mode":"unknown","server_time_utc":1726250022,"version":"1.17.5"}
======================

2.
===Start Request===
GET http://localhost:8200/v1/sys/auth/token/tune

===End Request===

Secret<BackendConfig>
======================
From Vault Server: 200-OK
{"max_lease_ttl":2764800,"force_no_cache":false,"token_type":"default-service","description":"token based credentials","default_lease_ttl":2764800,"request_id":"8e34dc30-e987-769f-e51e-0c809eca1306","lease_id":"","renewable":false,"lease_duration":0,"data":{"default_lease_ttl":2764800,"description":"token based credentials","force_no_cache":false,"max_lease_ttl":2764800,"token_type":"default-service"},"wrap_info":null,"warnings":null,"auth":null,"mount_type":"system"}

{"request_id":"8e34dc30-e987-769f-e51e-0c809eca1306","lease_id":"","renewable":false,"lease_duration":0,"data":{"default_lease_ttl":2764800,"force_no_cache":false,"max_lease_ttl":2764800},"wrap_info":null,"warnings":null,"auth":null,"mount_type":"system"}
======================

Secret<BackendConfig>
======================
From Vault Server: 200-OK
{"token_type":"default-service","listing_visibility":"hidden","description":"","default_lease_ttl":3600,"max_lease_ttl":4200,"force_no_cache":false,"request_id":"b456edef-b32d-5e99-e60b-81d08ca10919","lease_id":"","renewable":false,"lease_duration":0,"data":{"default_lease_ttl":3600,"description":"","force_no_cache":false,"listing_visibility":"hidden","max_lease_ttl":4200,"token_type":"default-service"},"wrap_info":null,"warnings":null,"auth":null,"mount_type":"system"}

{"request_id":"b456edef-b32d-5e99-e60b-81d08ca10919","lease_id":"","renewable":false,"lease_duration":0,"data":{"default_lease_ttl":3600,"force_no_cache":false,"max_lease_ttl":4200},"wrap_info":null,"warnings":null,"auth":null,"mount_type":"system"}
======================
28 changes: 27 additions & 1 deletion src/VaultSharp/V1/Commons/BackendConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace VaultSharp.Core
{
Expand Down Expand Up @@ -35,5 +36,30 @@ public class BackendConfig
/// </value>
[JsonPropertyName("max_lease_ttl")]
public int MaximumLeaseTtl { get; set; }

[JsonPropertyName("description")]
public string Description { get; set; }

[JsonPropertyName("audit_non_hmac_request_keys")]
public List<string> AuditNonHmacRequestKeys { get; set; }

[JsonPropertyName("audit_non_hmac_response_keys")]
public List<string> AuditNonHmacResponseKeys { get; set; }

[JsonPropertyName("listing_visibility")]
public BackendListingVisibility ListingVisibility { get; set; } = BackendListingVisibility.hidden;

[JsonPropertyName("passthrough_request_headers")]
public List<string> PassthroughRequestHeaders { get; set; }

[JsonPropertyName("allowed_response_headers")]
public List<string> AllowedResponseHeaders { get; set; }

[JsonPropertyName("allowed_managed_keys")]
public List<string> AllowedManagedKeys { get; set; }

[JsonPropertyName("plugin_version")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] // CRITICAL: Very very important
public string PluginVersion { get; set; }
}
}
36 changes: 0 additions & 36 deletions src/VaultSharp/V1/Commons/NewBackendConfig.cs

This file was deleted.

36 changes: 36 additions & 0 deletions src/VaultSharp/V1/SystemBackend/HealthStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ public class HealthStatus
[JsonPropertyName("cluster_id")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string ClusterId { get; set; }

/// <summary>
/// Gets or sets a value indicating whether this instance of Vault is an enterprise version.
/// </summary>
/// <value>
/// <c>true</c> if enterprise; otherwise, <c>false</c>.
/// </value>
[JsonPropertyName("enterprise")]
public bool Enterprise { get; set; }

/// <summary>
/// Gets or sets the echo_duration_ms
/// </summary>
/// <value>
/// The echo_duration_ms
/// </value>
[JsonPropertyName("echo_duration_ms")]
public long EchoDurationMilliseconds { get; set; }

/// <summary>
/// Gets or sets the clock_skew_ms
/// </summary>
/// <value>
/// The clock_skew_ms
/// </value>
[JsonPropertyName("clock_skew_ms")]
public long ClockSkewMilliseconds { get; set; }

/// <summary>
/// Gets or sets the replication_primary_canary_age_ms
/// </summary>
/// <value>
/// The replication_primary_canary_age_ms
/// </value>
[JsonPropertyName("replication_primary_canary_age_ms")]
public long ReplicationPrimaryCanaryAgeMilliseconds { get; set; }

/// <summary>
/// Gets the friendly server time from ServerTimeUtcUnixTimestamp
Expand Down
4 changes: 2 additions & 2 deletions src/VaultSharp/V1/SystemBackend/ISystemBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public interface ISystemBackend
/// <returns>
/// A task
/// </returns>
Task ConfigureAuthBackendAsync(string path, NewBackendConfig backendConfig);
Task ConfigureAuthBackendAsync(string path, BackendConfig backendConfig);

/// <summary>
/// Gets the capabilities of the token on the given path.
Expand Down Expand Up @@ -519,7 +519,7 @@ public interface ISystemBackend
/// <returns>
/// A task
/// </returns>
Task ConfigureSecretBackendAsync(string path, NewBackendConfig backendConfig);
Task ConfigureSecretBackendAsync(string path, BackendConfig backendConfig);

/// <summary>
/// Gets all the available policy names in the system.
Expand Down
4 changes: 2 additions & 2 deletions src/VaultSharp/V1/SystemBackend/SystemBackendProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public async Task<Secret<BackendConfig>> GetAuthBackendConfigAsync(string path)
return await _polymath.MakeVaultApiRequest<Secret<BackendConfig>>(resourcePath, HttpMethod.Get).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
}

public async Task ConfigureAuthBackendAsync(string path, NewBackendConfig backendConfig)
public async Task ConfigureAuthBackendAsync(string path, BackendConfig backendConfig)
{
var resourcePath = string.Format(CultureInfo.InvariantCulture, "v1/sys/auth/{0}/tune", path.Trim('/'));
await _polymath.MakeVaultApiRequest(resourcePath, HttpMethod.Post, backendConfig).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
Expand Down Expand Up @@ -460,7 +460,7 @@ public async Task<Secret<BackendConfig>> GetSecretBackendConfigAsync(string path
return await _polymath.MakeVaultApiRequest<Secret<BackendConfig>>(resourcePath, HttpMethod.Get).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
}

public async Task ConfigureSecretBackendAsync(string path, NewBackendConfig backendConfig)
public async Task ConfigureSecretBackendAsync(string path, BackendConfig backendConfig)
{
var resourcePath = string.Format(CultureInfo.InvariantCulture, "v1/sys/mounts/{0}/tune", path.Trim('/'));
await _polymath.MakeVaultApiRequest(resourcePath, HttpMethod.Post, backendConfig).ConfigureAwait(_polymath.VaultClientSettings.ContinueAsyncTasksOnCapturedContext);
Expand Down
4 changes: 2 additions & 2 deletions test/VaultSharp.Samples/Backends/SystemBackendSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private static void RunSystemBackendSamples()
Assert.Equal(2764800, backendConfig.Data.DefaultLeaseTtl);
Assert.Equal(2764800, backendConfig.Data.MaximumLeaseTtl);

var newBackendConfig = new NewBackendConfig
var newBackendConfig = new BackendConfig
{
DefaultLeaseTtl = 3600,
MaximumLeaseTtl = 4200,
Expand Down Expand Up @@ -494,7 +494,7 @@ private static void RunSystemBackendSamples()

var ttl = 36000;

_authenticatedVaultClient.V1.System.ConfigureSecretBackendAsync(newSecretBackend.Path, new NewBackendConfig { DefaultLeaseTtl = ttl, MaximumLeaseTtl = ttl, ForceNoCache = true }).Wait();
_authenticatedVaultClient.V1.System.ConfigureSecretBackendAsync(newSecretBackend.Path, new BackendConfig { DefaultLeaseTtl = ttl, MaximumLeaseTtl = ttl, ForceNoCache = true }).Wait();

var newMountConfig = _authenticatedVaultClient.V1.System.GetSecretBackendConfigAsync(newSecretBackend.Path).Result;
DisplayJson(newMountConfig);
Expand Down

0 comments on commit 4d4449b

Please sign in to comment.