Updated with secure cooke
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing

This commit is contained in:
Kasper Juul Hermansen 2021-11-16 23:28:16 +01:00
parent cb43207502
commit fd79027b37
Signed by: kjuulh
GPG Key ID: DCD9397082D97069
2 changed files with 8 additions and 2 deletions

View File

@ -65,7 +65,7 @@ namespace Todo.Api
app.UseRouting();
app.UseCors();
app.UseInfrastructure();
app.UseAuthentication();
app.UseAuthorization();

View File

@ -1,5 +1,6 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
@ -19,6 +20,7 @@ public static class DependencyInjection
.Bind(giteaOptions)
.ValidateDataAnnotations();
return services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
@ -36,7 +38,11 @@ public static class DependencyInjection
}).Services;
}
public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app) => app;
public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app) => app.UseCookiePolicy(
new CookiePolicyOptions
{
Secure = CookieSecurePolicy.Always
});
}
public class GiteaAuthOptions