This commit is contained in:
Zoe Roux 2020-03-30 18:15:07 +02:00
parent 77123ad870
commit 4636c9453c
4 changed files with 39 additions and 49 deletions

View File

@ -29,7 +29,7 @@ namespace Kyoo
AllowOfflineAccess = true, AllowOfflineAccess = true,
RequireClientSecret = false, RequireClientSecret = false,
RequireConsent = false, RequireConsent = false,
AccessTokenType = AccessTokenType.Reference, AccessTokenType = AccessTokenType.Jwt,
AllowedScopes = { "openid", "profile", "kyoo.read", "kyoo.write", "kyoo.play", "kyoo.download", "kyoo.admin" }, AllowedScopes = { "openid", "profile", "kyoo.read", "kyoo.write", "kyoo.play", "kyoo.download", "kyoo.admin" },
RedirectUris = { "/", "/silent" }, RedirectUris = { "/", "/silent" },
PostLogoutRedirectUris = { "/logout" } PostLogoutRedirectUris = { "/logout" }

View File

@ -3,6 +3,7 @@ using Kyoo.Api;
using Kyoo.Controllers; using Kyoo.Controllers;
using Kyoo.Models; using Kyoo.Models;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
@ -26,16 +27,14 @@ namespace Kyoo
// This method gets called by the runtime. Use this method to add services to the container. // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
// services.AddSpaStaticFiles(configuration => services.AddSpaStaticFiles(configuration =>
// { {
// configuration.RootPath = "wwwroot"; configuration.RootPath = "wwwroot";
// }); });
//
// services.AddControllers().AddNewtonsoftJson(); services.AddControllers().AddNewtonsoftJson();
// services.AddHttpClient(); services.AddHttpClient();
//
// string publicUrl = Configuration.GetValue<string>("public_url");
//
services.AddDbContext<DatabaseContext>(options => services.AddDbContext<DatabaseContext>(options =>
{ {
options.UseLazyLoadingProxies() options.UseLazyLoadingProxies()
@ -74,31 +73,22 @@ namespace Kyoo
.AddProfileService<AccountController>() .AddProfileService<AccountController>()
.AddDeveloperSigningCredential(); // TODO remove the developer signin .AddDeveloperSigningCredential(); // TODO remove the developer signin
services.AddAuthentication() services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddIdentityServerJwt(); .AddJwtBearer(options =>
{
// services.ConfigureApplicationCookie(options => options.Authority = publicUrl;
// { options.Audience = "Kyoo";
// options.Events.OnRedirectToAccessDenied = context => options.RequireHttpsMetadata = false;
// { });
// context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
// return Task.CompletedTask;
// };
// options.Events.OnRedirectToLogin = context =>
// {
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
// return Task.CompletedTask;
// };
// });
// services.AddAuthorization(options => services.AddAuthorization(options =>
// { {
// options.AddPolicy("Read", policy => policy.RequireClaim("read")); options.AddPolicy("Read", policy => policy.RequireClaim("read"));
// options.AddPolicy("Write", policy => policy.RequireClaim("write")); options.AddPolicy("Write", policy => policy.RequireClaim("write"));
// options.AddPolicy("Play", policy => policy.RequireClaim("play")); options.AddPolicy("Play", policy => policy.RequireClaim("play"));
// options.AddPolicy("Download", policy => policy.RequireClaim("download")); options.AddPolicy("Download", policy => policy.RequireClaim("download"));
// options.AddPolicy("Admin", policy => policy.RequireClaim("admin")); options.AddPolicy("Admin", policy => policy.RequireClaim("admin"));
// }); });
services.AddScoped<ILibraryManager, LibraryManager>(); services.AddScoped<ILibraryManager, LibraryManager>();
services.AddScoped<ICrawler, Crawler>(); services.AddScoped<ICrawler, Crawler>();
@ -123,18 +113,18 @@ namespace Kyoo
app.UseHsts(); app.UseHsts();
} }
// app.Use((ctx, next) => app.Use((ctx, next) =>
// { {
// ctx.Response.Headers.Remove("X-Powered-By"); ctx.Response.Headers.Remove("X-Powered-By");
// ctx.Response.Headers.Remove("Server"); ctx.Response.Headers.Remove("Server");
// ctx.Response.Headers.Add("Feature-Policy", "autoplay 'self'; fullscreen"); ctx.Response.Headers.Add("Feature-Policy", "autoplay 'self'; fullscreen");
// ctx.Response.Headers.Add("Content-Security-Policy", "default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob:; style-src 'self' 'unsafe-inline'"); ctx.Response.Headers.Add("Content-Security-Policy", "default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' data: blob:; style-src 'self' 'unsafe-inline'");
// ctx.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); ctx.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
// ctx.Response.Headers.Add("Referrer-Policy", "no-referrer"); ctx.Response.Headers.Add("Referrer-Policy", "no-referrer");
// ctx.Response.Headers.Add("Access-Control-Allow-Origin", "null"); ctx.Response.Headers.Add("Access-Control-Allow-Origin", "null");
// ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff"); ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff");
// return next(); return next();
// }); });
app.UseStaticFiles(); app.UseStaticFiles();
if (!env.IsDevelopment()) if (!env.IsDevelopment())

@ -1 +1 @@
Subproject commit 3f17ec96dac6cc641b875a0e3b201b8b75336d6d Subproject commit 92924ddfb62306c3e6ed7fe6462317f920686962

View File

@ -4,7 +4,7 @@
"https_port": 44300, "https_port": 44300,
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Trace",
"Microsoft": "Warning", "Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information" "Microsoft.Hosting.Lifetime": "Information"
} }