Skip to content

Commit

Permalink
Remove un-used basic auth package
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad committed Dec 4, 2024
1 parent 4835e40 commit b1d0c89
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 61 deletions.
1 change: 0 additions & 1 deletion TeachingRecordSystem/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
<PackageVersion Include="Hangfire.PostgreSql" Version="1.20.10" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
<PackageVersion Include="IdentityModel" Version="6.2.0" />
<PackageVersion Include="idunno.Authentication.Basic" Version="2.3.1" />
<PackageVersion Include="Joonasw.AspNetCore.SecurityHeaders" Version="5.0.0" />
<PackageVersion Include="JustEat.HttpClientInterception" Version="4.3.0" />
<PackageVersion Include="LinqKit" Version="1.2.5" />
Expand Down
36 changes: 0 additions & 36 deletions TeachingRecordSystem/src/TeachingRecordSystem.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,41 +69,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<IConfiguration>();
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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<PackageReference Include="AspNetCore.HealthChecks.Redis" />
<PackageReference Include="AutoMapper" />
<PackageReference Include="FluentValidation.AspNetCore" />
<PackageReference Include="idunno.Authentication.Basic" />
<PackageReference Include="MediatR" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,5 @@
"AllowVNextEndpoints": true,
"AuthorizeAccessIssuer": "https://localhost:7236",
"DetailedErrors": true,
"ApiClients": {
"developer": {
"ApiKey": [ "developer" ]
}
},
"AdminCredentials": {
"Username": "admin",
"Password": "test"
},
"StorageConnectionString": "UseDevelopmentStorage=true"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, )",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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, )",
Expand Down

0 comments on commit b1d0c89

Please sign in to comment.