Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused basic auth package #1729

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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<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
Loading