diff --git a/WebAPI/Controllers/AuthController.cs b/WebAPI/Controllers/AuthController.cs index 287592d..778055e 100644 --- a/WebAPI/Controllers/AuthController.cs +++ b/WebAPI/Controllers/AuthController.cs @@ -30,7 +30,7 @@ namespace WebAPI.Controllers { var settings = new GoogleJsonWebSignature.ValidationSettings() { - Audience = new List { configuration.GetValue("GoogleClientId") } + Audience = new List { configuration.GetValue("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("Secret")); + var key = Encoding.ASCII.GetBytes(configuration.GetValue("Secret")!); var expirationTime = DateTime.UtcNow.AddMinutes(5); var tokenDescriptor = new SecurityTokenDescriptor { diff --git a/WebAPI/Models/Layer.cs b/WebAPI/Models/Layer.cs index 0ba73f5..cce55b9 100644 --- a/WebAPI/Models/Layer.cs +++ b/WebAPI/Models/Layer.cs @@ -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] diff --git a/WebAPI/Program.cs b/WebAPI/Program.cs index 1ac5ac4..dfda5ac 100644 --- a/WebAPI/Program.cs +++ b/WebAPI/Program.cs @@ -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()) {