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:
Developer 02
2025-05-09 14:35:15 +02:00
parent bac1fb6054
commit 019abaffa6
7 changed files with 37 additions and 3 deletions

View 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; }
}

View File

@@ -0,0 +1,4 @@
namespace DigitalData.Auth.API.Models
{
public record ConsumerLogin(string Name, string Password);
}

View 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));
}
}

View File

@@ -0,0 +1,3 @@
namespace DigitalData.Auth.API.Models;
public record UserLogin(string Password, int? UserId = null, string? Username = null);