From 9d20b9ae7d802c115ebdbf5f1b0fe7e56e114291 Mon Sep 17 00:00:00 2001 From: James Gunn Date: Wed, 4 Dec 2024 17:12:10 +0000 Subject: [PATCH] Remove un-used basic auth package --- TeachingRecordSystem/Directory.Packages.props | 1 - .../src/TeachingRecordSystem.Api/Program.cs | 36 ------------------- .../TeachingRecordSystem.Api.csproj | 1 - .../appsettings.Development.json | 9 ----- .../packages.lock.json | 6 ---- .../packages.lock.json | 9 +---- 6 files changed, 1 insertion(+), 61 deletions(-) diff --git a/TeachingRecordSystem/Directory.Packages.props b/TeachingRecordSystem/Directory.Packages.props index 1b8524c9c..636123d49 100644 --- a/TeachingRecordSystem/Directory.Packages.props +++ b/TeachingRecordSystem/Directory.Packages.props @@ -35,7 +35,6 @@ - diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs index b030e6447..45c9cefdc 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs @@ -3,7 +3,6 @@ using System.Text.Json.Serialization.Metadata; using FluentValidation; using FluentValidation.AspNetCore; -using idunno.Authentication.Basic; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApiExplorer; using Microsoft.AspNetCore.Mvc.Formatters; @@ -71,41 +70,6 @@ public static void Main(string[] args) options.Authority = configuration.GetRequiredValue("AuthorizeAccessIssuer"); options.MapInboundClaims = false; options.TokenValidationParameters.ValidateAudience = false; - }) - .AddBasic(options => - { - options.Realm = "TeachingRecordSystem.Api"; - options.Events = new BasicAuthenticationEvents - { - OnValidateCredentials = static context => - { - var configuration = context.HttpContext.RequestServices.GetRequiredService(); - var username = configuration.GetRequiredValue("AdminCredentials:Username"); - var password = configuration.GetRequiredValue("AdminCredentials:Password"); - - if (context.Username == username && context.Password == password) - { - var claims = new[] - { - new Claim( - ClaimTypes.NameIdentifier, - context.Username, - ClaimValueTypes.String, - context.Options.ClaimsIssuer), - new Claim( - ClaimTypes.Name, - context.Username, - ClaimValueTypes.String, - context.Options.ClaimsIssuer) - }; - - context.Principal = new ClaimsPrincipal(new ClaimsIdentity(claims, context.Scheme.Name)); - context.Success(); - } - - return Task.CompletedTask; - } - }; }); services.AddAuthorization(options => diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj b/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj index 09de55569..5fc7020cb 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/TeachingRecordSystem.Api.csproj @@ -9,7 +9,6 @@ - diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Development.json b/TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Development.json index 600ea340b..5a196fbb9 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Development.json +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Development.json @@ -2,14 +2,5 @@ "AllowVNextEndpoints": true, "AuthorizeAccessIssuer": "https://localhost:7236", "DetailedErrors": true, - "ApiClients": { - "developer": { - "ApiKey": [ "developer" ] - } - }, - "AdminCredentials": { - "Username": "admin", - "Password": "test" - }, "StorageConnectionString": "UseDevelopmentStorage=true" } diff --git a/TeachingRecordSystem/src/TeachingRecordSystem.Api/packages.lock.json b/TeachingRecordSystem/src/TeachingRecordSystem.Api/packages.lock.json index 8917674a0..7d8b83a55 100644 --- a/TeachingRecordSystem/src/TeachingRecordSystem.Api/packages.lock.json +++ b/TeachingRecordSystem/src/TeachingRecordSystem.Api/packages.lock.json @@ -31,12 +31,6 @@ "FluentValidation.DependencyInjectionExtensions": "11.5.1" } }, - "idunno.Authentication.Basic": { - "type": "Direct", - "requested": "[2.3.1, )", - "resolved": "2.3.1", - "contentHash": "99EoiqTy6hYDvHehG1JLlprkB08ioR/hsnCpPhvDJJeZ0JOKNpoL+7C2jLC1r5vo0G5kerOPqdhdSHF3Ss2blw==" - }, "MediatR": { "type": "Direct", "requested": "[12.2.0, )", diff --git a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/packages.lock.json b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/packages.lock.json index 92d461aec..08f8b39e7 100644 --- a/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/packages.lock.json +++ b/TeachingRecordSystem/tests/TeachingRecordSystem.Api.Tests/packages.lock.json @@ -2429,8 +2429,7 @@ "Swashbuckle.AspNetCore": "[6.6.2, )", "Swashbuckle.AspNetCore.Annotations": "[6.6.2, )", "TeachingRecordSystem.Core": "[1.0.0, )", - "TeachingRecordSystem.ServiceDefaults": "[1.0.0, )", - "idunno.Authentication.Basic": "[2.3.1, )" + "TeachingRecordSystem.ServiceDefaults": "[1.0.0, )" } }, "teachingrecordsystem.core": { @@ -2751,12 +2750,6 @@ "resolved": "6.2.0", "contentHash": "4AXZ6Tp+DNwrSSeBziiX/231i8ZpD77A9nEMyc68gLSCWG0kgWsIBeFquYcBebiIPkfB7GEXzCYuuLeR1QZJIQ==" }, - "idunno.Authentication.Basic": { - "type": "CentralTransitive", - "requested": "[2.3.1, )", - "resolved": "2.3.1", - "contentHash": "99EoiqTy6hYDvHehG1JLlprkB08ioR/hsnCpPhvDJJeZ0JOKNpoL+7C2jLC1r5vo0G5kerOPqdhdSHF3Ss2blw==" - }, "MediatR": { "type": "CentralTransitive", "requested": "[12.2.0, )",