Saving
This commit is contained in:
1 parent
9719a0c0fd
commit
1e66851113
146 files changed
+738
-382
No files matched your search
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
using PrivaPub.Services;
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace PrivaPub.Extensions
|
||||
{
|
||||
public static class AddAuthExtension
|
||||
{
|
||||
public static AuthenticationBuilder AddPrivaPubAuth(this AuthenticationBuilder builder, IConfiguration configuration)
|
||||
{
|
||||
builder.AddJwtBearer(options => {
|
||||
#if DEBUG
|
||||
options.RequireHttpsMetadata = false;
|
||||
#endif
|
||||
options.TokenValidationParameters = new()
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = configuration["AppConfiguration:Jwt:Issuer"],
|
||||
ValidAudience = configuration["AppConfiguration:Jwt:Audience"],
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["AppConfiguration:Jwt:Key"]))
|
||||
};
|
||||
options.Events = new JwtEvents();
|
||||
});
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user