Merging the authorization branch

This commit is contained in:
Zoe Roux
2021-05-05 22:33:49 +02:00
11 changed files with 136 additions and 110 deletions
+4 -3
View File
@@ -79,8 +79,10 @@ namespace Kyoo.Authentication
// .AddDefaultTokenProviders()
// .AddEntityFrameworkStores<IdentityDatabase>();
services.Configure<PermissionOption>(_configuration.GetSection(PermissionOption.Path));
CertificateOption certificateOptions = new();
_configuration.GetSection(CertificateOption.Path).Bind(certificateOptions);
services.AddIdentityServer(options =>
{
options.IssuerUri = publicUrl;
@@ -136,7 +138,7 @@ namespace Kyoo.Authentication
{
policy.AuthenticationSchemes.Add(IdentityConstants.ApplicationScheme);
policy.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
policy.AddRequirements(new AuthorizationValidator(permission));
policy.AddRequirements(new AuthRequirement(permission));
policy.RequireScope($"kyoo.{permission.ToLower()}");
});
}
@@ -153,8 +155,6 @@ namespace Kyoo.Authentication
/// <inheritdoc />
public void ConfigureAspNet(IApplicationBuilder app)
{
app.UseAuthorization();
app.UseCookiePolicy(new CookiePolicyOptions
{
MinimumSameSitePolicy = SameSiteMode.Strict
@@ -166,6 +166,7 @@ namespace Kyoo.Authentication
return next();
});
app.UseIdentityServer();
app.UseAuthorization();
}
}
}