replace credential

This commit is contained in:
Wenjie Yu 2021-06-02 10:52:51 +08:00
parent 0421be2221
commit 8ca2e75bed
6 changed files with 36 additions and 7 deletions

View File

@ -10,6 +10,7 @@ using Serilog;
using System; using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using Azure.Core;
var configuration = GetConfiguration(); var configuration = GetConfiguration();
@ -89,7 +90,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();

View File

@ -15,6 +15,7 @@ using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using Azure.Identity; using Azure.Identity;
using Azure.Core;
var configuration = GetConfiguration(); var configuration = GetConfiguration();
@ -109,7 +110,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();

View File

@ -12,6 +12,7 @@ using Serilog;
using System; using System;
using System.IO; using System.IO;
using Azure.Identity; using Azure.Identity;
using Azure.Core;
string Namespace = typeof(Startup).Namespace; string Namespace = typeof(Startup).Namespace;
string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1); string AppName = Namespace.Substring(Namespace.LastIndexOf('.', Namespace.LastIndexOf('.') - 1) + 1);
@ -94,7 +95,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();

View File

@ -14,6 +14,7 @@ using System;
using System.IO; using System.IO;
using System.Net; using System.Net;
using Azure.Identity; using Azure.Identity;
using Azure.Core;
var configuration = GetConfiguration(); var configuration = GetConfiguration();
@ -101,7 +102,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();

View File

@ -8,7 +8,7 @@ using Serilog;
using System; using System;
using System.IO; using System.IO;
using Azure.Identity; using Azure.Identity;
using Azure.Core;
var configuration = GetConfiguration(); var configuration = GetConfiguration();
@ -70,7 +70,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using WebStatus; using WebStatus;
using Azure.Identity; using Azure.Identity;
using Azure.Core;
var configuration = GetConfiguration(); var configuration = GetConfiguration();
@ -71,7 +72,11 @@ IConfiguration GetConfiguration()
if (config.GetValue<bool>("UseVault", false)) if (config.GetValue<bool>("UseVault", false))
{ {
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), new DefaultAzureCredential()); TokenCredential credential = new ClientSecretCredential(
config["Vault:TenantId"],
config["Vault:ClientId"],
config["Vault:ClientSecret"]);
builder.AddAzureKeyVault(new Uri($"https://{config["Vault:Name"]}.vault.azure.net/"), credential);
} }
return builder.Build(); return builder.Build();