WIP: duplicate administration layer
This commit is contained in:
@@ -30,7 +30,7 @@ namespace WebAPI.Controllers
|
||||
{
|
||||
var settings = new GoogleJsonWebSignature.ValidationSettings()
|
||||
{
|
||||
Audience = new List<string> { configuration.GetValue<string>("GoogleClientId") }
|
||||
Audience = new List<string> { configuration.GetValue<string>("GoogleClientId")! }
|
||||
};
|
||||
var payload = await GoogleJsonWebSignature.ValidateAsync(credential, settings);
|
||||
var user = db.Users.Where(x => x.Email == payload.Email).FirstOrDefault();
|
||||
@@ -46,7 +46,7 @@ namespace WebAPI.Controllers
|
||||
|
||||
private dynamic JWTGenerator(User user)
|
||||
{
|
||||
var key = Encoding.ASCII.GetBytes(configuration.GetValue<string>("Secret"));
|
||||
var key = Encoding.ASCII.GetBytes(configuration.GetValue<string>("Secret")!);
|
||||
var expirationTime = DateTime.UtcNow.AddMinutes(5);
|
||||
var tokenDescriptor = new SecurityTokenDescriptor
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace WebAPI.Models
|
||||
[Required]
|
||||
public string? Source { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public string? Name { get; set; }
|
||||
[Required]
|
||||
public LayerType Type { get; set; }
|
||||
[Required]
|
||||
|
||||
@@ -32,6 +32,7 @@ builder.Services.AddCors(options =>
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
|
||||
builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||
@@ -51,6 +52,7 @@ builder.Services.AddAuthentication(options =>
|
||||
});
|
||||
builder.Services.AddAuthentication();
|
||||
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
@@ -60,6 +62,7 @@ builder.Services.AddSingleton(typeof(GoogleDriveHelper));
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
string token = context.Request.Headers["Authorization"].ToString();
|
||||
@@ -71,6 +74,7 @@ app.Use(async (context, next) =>
|
||||
await next(context);
|
||||
});
|
||||
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user