update the project file
This commit is contained in:
parent
66a7ae1bc6
commit
6ee4eba6d9
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
|||||||
using VaultSharp;
|
using VaultSharp;
|
||||||
using VaultSharp.V1.AuthMethods;
|
using VaultSharp.V1.AuthMethods;
|
||||||
using VaultSharp.V1.AuthMethods.Token;
|
using VaultSharp.V1.AuthMethods.Token;
|
||||||
|
using VaultSharp.V1.Commons;
|
||||||
using YamlDotNet.Core.Tokens;
|
using YamlDotNet.Core.Tokens;
|
||||||
|
|
||||||
namespace Acme.BookStore.Controllers;
|
namespace Acme.BookStore.Controllers;
|
||||||
@ -25,16 +26,10 @@ public class CheckController : Controller
|
|||||||
this._configuration = configuration;
|
this._configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("GetVal")]
|
[HttpGet("GetValue")]
|
||||||
public async Task<string> GetValueAsync()
|
public string GetValue()
|
||||||
{
|
{
|
||||||
var authMethod = new TokenAuthMethodInfo(_configuration.GetValue<string>("vaultsetting:token"));
|
return _configuration.GetConnectionString("Default") ?? string.Empty;
|
||||||
var vaultClientSettings = new VaultClientSettings(_configuration.GetValue<string>("vaultsetting:url"), authMethod);
|
|
||||||
var vaultClient = new VaultClient(vaultClientSettings);
|
|
||||||
var result = await vaultClient.V1.Secrets.KeyValue.V2.ReadSecretAsync(_configuration.GetValue<string>("vaultsetting:path"), mountPoint: _configuration.GetValue<string>("vaultsetting:mp"));
|
|
||||||
|
|
||||||
return result.Data.Data.TryGetValue("testvalue", out var value)
|
|
||||||
? value.ToString() ?? ""
|
|
||||||
: _configuration.GetConnectionString("Default") ?? "";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user