diff --git a/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Controllers/AuthController.cs b/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Controllers/AuthController.cs index bc2c97e..e0c8dbf 100644 --- a/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Controllers/AuthController.cs +++ b/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Controllers/AuthController.cs @@ -7,8 +7,17 @@ namespace Suspectus.Gandalf.Bridgekeeper.Api.Controllers; [ApiController] [Route("api/[controller]")] -public class AuthController(IPalantirClient client) : ControllerBase +public class AuthController : ControllerBase { + private readonly IPalantirClient _client; + private readonly IPalantirAuthClient _authClient; + + public AuthController(IPalantirClient client, IPalantirAuthClient authClient) + { + _client = client; + _authClient = authClient; + } + [HttpGet("[action]")] public async Task Check() { @@ -18,7 +27,7 @@ public class AuthController(IPalantirClient client) : ControllerBase [HttpPost("[action]")] public async Task Login([FromBody] LoginCommand loginCommand) { - var validationResult = await client.Auth.ValidateCredentials(new ValidateCredentialsCommand { Password = loginCommand.Password, UsernameOrEmail = loginCommand.UsernameOrEmail }); + var validationResult = await _client.Auth.ValidateCredentials(new ValidateCredentialsCommand { Password = loginCommand.Password, UsernameOrEmail = loginCommand.UsernameOrEmail }); return validationResult.Match(valid => { diff --git a/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Program.cs b/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Program.cs index d7b2ee0..25f01b4 100644 --- a/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Program.cs +++ b/src/dotnet/Suspectus.Gandalf.Bridgekeeper.Api/Program.cs @@ -2,11 +2,10 @@ using Suspectus.Gandalf.Palantir.Client.Extensions; var builder = WebApplication.CreateBuilder(args); +builder.Services.AddPalantirClient(); builder.Services.AddControllers(); builder.Services.AddOpenApi(); -builder.Services.AddPalantirClient(); - var app = builder.Build(); if (app.Environment.IsDevelopment()) diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Client/Extensions/ServiceCollectionExtensions.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Client/Extensions/ServiceCollectionExtensions.cs index 19c404a..4d477e0 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Client/Extensions/ServiceCollectionExtensions.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Client/Extensions/ServiceCollectionExtensions.cs @@ -6,8 +6,15 @@ public static class ServiceCollectionExtensions { public static IServiceCollection AddPalantirClient(this IServiceCollection services) { - services.AddHttpClient(opt => opt.BaseAddress = new Uri("https://localhost:7269/")); // TODO: WTF BRO WHY YOU DONT WORK - services.AddScoped(); + services.AddHttpClient(opt => + { + opt.BaseAddress = new Uri("https://localhost:7269/api/auth/"); + }) + .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler //TODO: Remove this in production + { + ServerCertificateCustomValidationCallback = + HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }); services.AddScoped(); return services; }