OPC # 0001: Extract Clarity into standalone repo
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using Clarity.Server.Data;
|
||||
using System.Runtime.Serialization;
|
||||
using VaultSharp;
|
||||
using VaultSharp.Core;
|
||||
using VaultSharp.V1.AuthMethods;
|
||||
using VaultSharp.V1.AuthMethods.Token;
|
||||
|
||||
namespace Clarity.Server
|
||||
{
|
||||
public static class VaultSharpExtensions
|
||||
{
|
||||
public static IServiceCollection AddClarityVaultCryptography(this IServiceCollection services, IConfiguration config)
|
||||
{
|
||||
var vaultAddress = config["Vault:Address"] ?? "http://localhost:8200";
|
||||
var vaultToken = config["Vault:Token"] ?? "root";
|
||||
|
||||
IAuthMethodInfo authMethod = new TokenAuthMethodInfo(vaultToken);
|
||||
var vaultClientSettings = new VaultClientSettings(vaultAddress, authMethod);
|
||||
IVaultClient vaultClient = new VaultClient(vaultClientSettings);
|
||||
services.AddSingleton<IVaultClient>(vaultClient);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user