2023-02-18 08:52:17 +01:00
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
|
|
|
|
2023-02-19 00:43:43 +01:00
|
|
|
using PrivaPub.Services;
|
2023-02-18 08:52:17 +01:00
|
|
|
|
2023-02-19 00:43:43 +01:00
|
|
|
namespace PrivaPub.Extensions
|
2023-02-18 08:52:17 +01:00
|
|
|
{
|
|
|
|
|
public static class AddAuthExtension
|
|
|
|
|
{
|
2023-02-19 00:43:43 +01:00
|
|
|
public static AuthenticationBuilder AddPrivaPubAuth(this AuthenticationBuilder builder, IConfiguration configuration)
|
2023-02-18 08:52:17 +01:00
|
|
|
{
|
|
|
|
|
builder.AddJwtBearer(options => {
|
|
|
|
|
#if DEBUG
|
|
|
|
|
options.RequireHttpsMetadata = false;
|
|
|
|
|
#endif
|
2026-10-04 10:03:46 +02:00
|
|
|
options.TokenValidationParameters = RootJwt.Parameters(configuration);
|
2023-02-18 08:52:17 +01:00
|
|
|
options.Events = new JwtEvents();
|
|
|
|
|
});
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|