mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-06 20:08:40 +00:00
Refactor deserialization and authentication (#550)
* Refactor deserialization and more * Refactor authentication flow * Fix unit tests * Make deserialization better
This commit is contained in:
parent
505b5eb03b
commit
b3a00da554
48 changed files with 575 additions and 589 deletions
|
@ -3,6 +3,9 @@ using LBPUnion.ProjectLighthouse.Logging;
|
|||
using LBPUnion.ProjectLighthouse.Middlewares;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Middlewares;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Startup;
|
||||
|
@ -21,6 +24,19 @@ public class GameServerStartup
|
|||
{
|
||||
services.AddControllers();
|
||||
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = "tokenAuth";
|
||||
options.AddScheme<TokenAuthHandler>("tokenAuth", null);
|
||||
});
|
||||
|
||||
services.AddAuthorization(o =>
|
||||
{
|
||||
AuthorizationPolicyBuilder builder = new("tokenAuth");
|
||||
builder = builder.RequireClaim("userId");
|
||||
o.DefaultPolicy = builder.Build();
|
||||
});
|
||||
|
||||
services.AddMvc
|
||||
(
|
||||
options =>
|
||||
|
@ -64,12 +80,14 @@ public class GameServerStartup
|
|||
app.UseForwardedHeaders();
|
||||
|
||||
app.UseMiddleware<RequestLogMiddleware>();
|
||||
app.UseMiddleware<RateLimitMiddleware>();
|
||||
app.UseMiddleware<DigestMiddleware>(computeDigests);
|
||||
app.UseMiddleware<SetLastContactMiddleware>();
|
||||
app.UseMiddleware<RateLimitMiddleware>();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints => endpoints.MapControllers());
|
||||
app.UseEndpoints(endpoints => endpoints.MapRazorPages());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue