Added authentication for the node against the api server. Cleaned up routes
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MoonCore.Extensions;
|
||||
using Moonlight.ApiServer.Interfaces.Startup;
|
||||
using MoonlightServers.ApiServer.Database;
|
||||
using MoonlightServers.ApiServer.Implementations;
|
||||
|
||||
namespace MoonlightServers.ApiServer.Startup;
|
||||
|
||||
@@ -13,6 +16,24 @@ public class PluginStartup : IPluginStartup
|
||||
|
||||
builder.Services.AddDbContext<ServersDataContext>();
|
||||
|
||||
// Configure authentication for the remote endpoints
|
||||
builder.Services
|
||||
.AddAuthentication()
|
||||
.AddJwtBearer("serverNodeAuthentication", options =>
|
||||
{
|
||||
options.TokenValidationParameters = new()
|
||||
{
|
||||
ClockSkew = TimeSpan.Zero,
|
||||
ValidateIssuer = false,
|
||||
ValidateActor = false,
|
||||
ValidateLifetime = true,
|
||||
ValidateAudience = false,
|
||||
ValidateIssuerSigningKey = true
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton<IConfigureOptions<JwtBearerOptions>, NodeJwtBearerOptions>();
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user