Refactor namespaces and introduce backdoor authentication
This commit refactors the namespace from `DigitalData.Auth.API.Dto` to `DigitalData.Auth.API.Models` in several files, improving the organization of data structures. A new `Backdoor` class is added to support backdoor authentication, along with a method in `DependencyInjection.cs` to register backdoor configurations. Additionally, `AuthApiParams` configuration is included in `Program.cs`, and a new JSON structure for backdoor users is introduced in `backdoors.json`. These changes enhance the codebase's structure and functionality.
This commit is contained in:
parent
bac1fb6054
commit
019abaffa6
@ -5,7 +5,7 @@ using Microsoft.Extensions.Options;
|
|||||||
using DigitalData.UserManager.Application.Contracts;
|
using DigitalData.UserManager.Application.Contracts;
|
||||||
using DigitalData.UserManager.Application.DTOs.User;
|
using DigitalData.UserManager.Application.DTOs.User;
|
||||||
using DigitalData.Core.Abstractions.Application;
|
using DigitalData.Core.Abstractions.Application;
|
||||||
using DigitalData.Auth.API.Dto;
|
using DigitalData.Auth.API.Models;
|
||||||
using DigitalData.Auth.API.Services.Contracts;
|
using DigitalData.Auth.API.Services.Contracts;
|
||||||
using DigitalData.Auth.API.Entities;
|
using DigitalData.Auth.API.Entities;
|
||||||
using DigitalData.Core.DTO;
|
using DigitalData.Core.DTO;
|
||||||
|
|||||||
10
src/DigitalData.Auth.API/Models/Backdoor.cs
Normal file
10
src/DigitalData.Auth.API/Models/Backdoor.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace DigitalData.Auth.API.Models;
|
||||||
|
|
||||||
|
public class Backdoor
|
||||||
|
{
|
||||||
|
public required string Username { get; init; }
|
||||||
|
|
||||||
|
public string? Password { get; init; }
|
||||||
|
|
||||||
|
public string? PasswordHash { get; init; }
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace DigitalData.Auth.API.Dto
|
namespace DigitalData.Auth.API.Models
|
||||||
{
|
{
|
||||||
public record ConsumerLogin(string Name, string Password);
|
public record ConsumerLogin(string Name, string Password);
|
||||||
}
|
}
|
||||||
12
src/DigitalData.Auth.API/Models/DependencyInjection.cs
Normal file
12
src/DigitalData.Auth.API/Models/DependencyInjection.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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.Get<IEnumerable<Backdoor>>() ?? Enumerable.Empty<Backdoor>();
|
||||||
|
return services.AddSingleton(Options.Create(backdoors));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,3 @@
|
|||||||
namespace DigitalData.Auth.API.Dto;
|
namespace DigitalData.Auth.API.Models;
|
||||||
|
|
||||||
public record UserLogin(string Password, int? UserId = null, string? Username = null);
|
public record UserLogin(string Password, int? UserId = null, string? Username = null);
|
||||||
@ -24,11 +24,14 @@ try
|
|||||||
|
|
||||||
builder.Configuration.AddJsonFile("consumer-repository.json", true, true);
|
builder.Configuration.AddJsonFile("consumer-repository.json", true, true);
|
||||||
|
|
||||||
|
builder.Configuration.AddJsonFile("consumer-repository.json", true, true);
|
||||||
|
|
||||||
var config = builder.Configuration;
|
var config = builder.Configuration;
|
||||||
|
|
||||||
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.Configure<>
|
||||||
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"));
|
||||||
|
|||||||
9
src/DigitalData.Auth.API/backdoors.json
Normal file
9
src/DigitalData.Auth.API/backdoors.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"backdoors": [
|
||||||
|
{
|
||||||
|
"Username": "Foo",
|
||||||
|
"Password": null,
|
||||||
|
"PasswordHash": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user