Refactor configuration setup and error handling
- Added custom configuration sources to the builder. - Removed Azure Key Vault integration for secret management.
This commit is contained in:
parent
ba01cfcaf7
commit
29e1f2fd62
@ -22,17 +22,7 @@ builder.AddCustomConfigurationSources();
|
|||||||
WebApplication? app = null;
|
WebApplication? app = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var keyVaultName = builder.Configuration["KeyVaultName"] ?? "";
|
builder.AddCustomConfigurationSources();
|
||||||
if (!string.IsNullOrEmpty(keyVaultName))
|
|
||||||
{
|
|
||||||
var keyVaultUri = $"https://{keyVaultName}.vault.azure.net/";
|
|
||||||
builder.Configuration.AddAzureKeyVault(
|
|
||||||
new Uri(keyVaultUri),
|
|
||||||
new DefaultAzureCredential(),
|
|
||||||
new SurgeKeyVaultSecretManager()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
builder.Services.AddSingleton<ILoggingService, LoggingService>();
|
|
||||||
|
|
||||||
var jwtKey = Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Secret"]!);
|
var jwtKey = Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Secret"]!);
|
||||||
builder.Services.AddAuthentication(options =>
|
builder.Services.AddAuthentication(options =>
|
||||||
@ -57,7 +47,6 @@ try
|
|||||||
|
|
||||||
builder.Services.AddHttpContextAccessor();
|
builder.Services.AddHttpContextAccessor();
|
||||||
|
|
||||||
|
|
||||||
Factory.RegisterDefaultServices(builder.Services,
|
Factory.RegisterDefaultServices(builder.Services,
|
||||||
adminContextProvider: provider =>
|
adminContextProvider: provider =>
|
||||||
{
|
{
|
||||||
@ -138,8 +127,6 @@ try
|
|||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user