JWT Authentication
This commit is contained in:
@@ -5,6 +5,8 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Prospect.Server.Api.Config;
|
||||
using Prospect.Server.Api.Middleware;
|
||||
using Prospect.Server.Api.Services.Auth;
|
||||
using Prospect.Server.Api.Services.Auth.User;
|
||||
using Prospect.Server.Api.Services.Database;
|
||||
using Serilog;
|
||||
|
||||
@@ -21,11 +23,21 @@ namespace Prospect.Server.Api
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<AuthTokenSettings>(Configuration.GetSection(nameof(AuthTokenSettings)));
|
||||
services.Configure<DatabaseSettings>(Configuration.GetSection(nameof(DatabaseSettings)));
|
||||
services.Configure<PlayFabSettings>(Configuration.GetSection(nameof(PlayFabSettings)));
|
||||
|
||||
services.AddSingleton<AuthTokenService>();
|
||||
services.AddSingleton<DbUserService>();
|
||||
services.AddSingleton<DbEntityService>();
|
||||
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = UserAuthenticationOptions.DefaultScheme;
|
||||
options.DefaultChallengeScheme = UserAuthenticationOptions.DefaultScheme;
|
||||
})
|
||||
.AddUserAuthentication(_ => {})
|
||||
.AddEntityAuthentication(_ => {});
|
||||
|
||||
services.AddControllers();
|
||||
}
|
||||
@@ -40,6 +52,8 @@ namespace Prospect.Server.Api
|
||||
app.UseSerilogRequestLogging();
|
||||
app.UseMiddleware<RequestLoggerMiddleware>();
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
|
||||
Reference in New Issue
Block a user