mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
IT WORKS
This commit is contained in:
parent
77123ad870
commit
4636c9453c
@ -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" }
|
||||||
|
@ -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 =>
|
||||||
|
{
|
||||||
|
options.Authority = publicUrl;
|
||||||
|
options.Audience = "Kyoo";
|
||||||
|
options.RequireHttpsMetadata = false;
|
||||||
|
});
|
||||||
|
|
||||||
// services.ConfigureApplicationCookie(options =>
|
services.AddAuthorization(options =>
|
||||||
// {
|
{
|
||||||
// options.Events.OnRedirectToAccessDenied = context =>
|
options.AddPolicy("Read", policy => policy.RequireClaim("read"));
|
||||||
// {
|
options.AddPolicy("Write", policy => policy.RequireClaim("write"));
|
||||||
// context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
options.AddPolicy("Play", policy => policy.RequireClaim("play"));
|
||||||
// return Task.CompletedTask;
|
options.AddPolicy("Download", policy => policy.RequireClaim("download"));
|
||||||
// };
|
options.AddPolicy("Admin", policy => policy.RequireClaim("admin"));
|
||||||
// options.Events.OnRedirectToLogin = context =>
|
});
|
||||||
// {
|
|
||||||
// context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
|
|
||||||
// return Task.CompletedTask;
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
|
|
||||||
// services.AddAuthorization(options =>
|
|
||||||
// {
|
|
||||||
// options.AddPolicy("Read", policy => policy.RequireClaim("read"));
|
|
||||||
// options.AddPolicy("Write", policy => policy.RequireClaim("write"));
|
|
||||||
// options.AddPolicy("Play", policy => policy.RequireClaim("play"));
|
|
||||||
// options.AddPolicy("Download", policy => policy.RequireClaim("download"));
|
|
||||||
// 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
|
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user