Refactor backdoor configuration handling
Removed the `AddBackdoors` method from `DependencyInjection.cs` and replaced its usage in `Program.cs` with `Configure<Backdoor>`. Updated `using` directives to include `Microsoft.Extensions.DependencyInjection`. Added a new `BackdoorParams` class to encapsulate backdoor configuration settings.
This commit is contained in:
parent
3336487bde
commit
0460466364
8
src/DigitalData.Auth.API/Config/BackdoorParams.cs
Normal file
8
src/DigitalData.Auth.API/Config/BackdoorParams.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
using DigitalData.Auth.API.Models;
|
||||||
|
|
||||||
|
namespace DigitalData.Auth.API.Config;
|
||||||
|
|
||||||
|
public class BackdoorParams
|
||||||
|
{
|
||||||
|
public IEnumerable<Backdoor> Backdoors { get; set; } = new List<Backdoor>();
|
||||||
|
}
|
||||||
@ -1,12 +0,0 @@
|
|||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace DigitalData.Auth.API.Models;
|
|
||||||
|
|
||||||
public static class DependencyInjection
|
|
||||||
{
|
|
||||||
public static IServiceCollection AddBackdoors(this IServiceCollection services, IConfiguration configuration)
|
|
||||||
{
|
|
||||||
var backdoors = configuration.GetSection("backdoors").Get<IEnumerable<Backdoor>>() ?? Enumerable.Empty<Backdoor>();
|
|
||||||
return services.AddSingleton(Options.Create(backdoors));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -10,6 +10,7 @@ using DigitalData.Core.Security.Extensions;
|
|||||||
using DigitalData.UserManager.Application;
|
using DigitalData.UserManager.Application;
|
||||||
using DigitalData.UserManager.Application.DTOs.User;
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.IdentityModel.JsonWebTokens;
|
using Microsoft.IdentityModel.JsonWebTokens;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
@ -34,7 +35,7 @@ try
|
|||||||
var apiParams = config.Get<AuthApiParams>() ?? throw new InvalidOperationException("AuthApiOptions is missing or invalid in appsettings.");
|
var apiParams = config.Get<AuthApiParams>() ?? throw new InvalidOperationException("AuthApiOptions is missing or invalid in appsettings.");
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddBackdoors(config);
|
builder.Services.Configure<Backdoor>(config.GetSection("Backdoors"));
|
||||||
builder.Services.Configure<AuthApiParams>(config);
|
builder.Services.Configure<AuthApiParams>(config);
|
||||||
builder.Services.AddAuthService(config);
|
builder.Services.AddAuthService(config);
|
||||||
builder.Services.AddRSAPool(config.GetSection("CryptParams"));
|
builder.Services.AddRSAPool(config.GetSection("CryptParams"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user