diff --git a/Kyoo.Authentication/AuthenticationModule.cs b/Kyoo.Authentication/AuthenticationModule.cs index 9018ba79..9c7c3687 100644 --- a/Kyoo.Authentication/AuthenticationModule.cs +++ b/Kyoo.Authentication/AuthenticationModule.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Reflection; using IdentityServer4.Extensions; using IdentityServer4.Models; using IdentityServer4.Services; @@ -13,9 +15,11 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Logging; +using SameSiteMode = Microsoft.AspNetCore.Http.SameSiteMode; namespace Kyoo.Authentication { @@ -80,7 +84,7 @@ namespace Kyoo.Authentication /// public void Configure(IServiceCollection services, ICollection availableTypes) { - string publicUrl = _configuration.GetValue("public_url").TrimEnd('/'); + string publicUrl = _configuration.GetValue("publicUrl").TrimEnd('/'); if (_environment.IsDevelopment()) IdentityModelEventSource.ShowPII = true; @@ -141,11 +145,26 @@ namespace Kyoo.Authentication app.UseAuthentication(); app.Use((ctx, next) => { - ctx.SetIdentityServerOrigin(_configuration.GetValue("public_url")); + ctx.SetIdentityServerOrigin(_configuration.GetValue("publicUrl").TrimEnd('/')); return next(); }); app.UseIdentityServer(); app.UseAuthorization(); + + PhysicalFileProvider provider = new(Path.Combine( + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, + "login")); + app.UseDefaultFiles(new DefaultFilesOptions + { + RequestPath = new PathString("/login"), + FileProvider = provider, + RedirectToAppendTrailingSlash = true + }); + app.UseStaticFiles(new StaticFileOptions + { + RequestPath = new PathString("/login"), + FileProvider = provider + }); } } } \ No newline at end of file diff --git a/Kyoo.Authentication/Kyoo.Authentication.csproj b/Kyoo.Authentication/Kyoo.Authentication.csproj index b334a943..2cde6c7e 100644 --- a/Kyoo.Authentication/Kyoo.Authentication.csproj +++ b/Kyoo.Authentication/Kyoo.Authentication.csproj @@ -13,6 +13,7 @@ Zoe Roux https://github.com/AnonymusRaccoon/Kyoo default + ../Kyoo.WebLogin/ @@ -21,12 +22,29 @@ - - - + all false + runtime + + + + + + + + + login/%(LoginFiles.RecursiveDir)%(LoginFiles.Filename)%(LoginFiles.Extension) + PreserveNewest + true + + + + + + + diff --git a/Kyoo.CommonAPI/CrudApi.cs b/Kyoo.CommonAPI/CrudApi.cs index 06713c66..75a2758c 100644 --- a/Kyoo.CommonAPI/CrudApi.cs +++ b/Kyoo.CommonAPI/CrudApi.cs @@ -21,7 +21,7 @@ namespace Kyoo.CommonApi public CrudApi(IRepository repository, IConfiguration configuration) { _repository = repository; - BaseURL = configuration.GetValue("public_url").TrimEnd('/'); + BaseURL = configuration.GetValue("publicUrl").TrimEnd('/'); } diff --git a/Kyoo.Postgresql/Kyoo.Postgresql.csproj b/Kyoo.Postgresql/Kyoo.Postgresql.csproj index c9067984..52c9041b 100644 --- a/Kyoo.Postgresql/Kyoo.Postgresql.csproj +++ b/Kyoo.Postgresql/Kyoo.Postgresql.csproj @@ -27,9 +27,15 @@ - - + + all + false + runtime + + all + false + runtime diff --git a/Kyoo/Controllers/PluginManager.cs b/Kyoo/Controllers/PluginManager.cs index c17e3230..321d2f57 100644 --- a/Kyoo/Controllers/PluginManager.cs +++ b/Kyoo/Controllers/PluginManager.cs @@ -218,6 +218,7 @@ namespace Kyoo.Controllers }); if (existing != null) return existing; + // TODO load the assembly from the common folder if the file exists (this would allow shared libraries) string assemblyPath = _resolver.ResolveAssemblyToPath(assemblyName); if (assemblyPath != null) return LoadFromAssemblyPath(assemblyPath); diff --git a/Kyoo/Kyoo.csproj b/Kyoo/Kyoo.csproj index 5804420f..77c01a03 100644 --- a/Kyoo/Kyoo.csproj +++ b/Kyoo/Kyoo.csproj @@ -6,7 +6,6 @@ Latest false ../Kyoo.WebApp/ - ../Kyoo.WebLogin/ ../Kyoo.Transcoder/ $(DefaultItemExcludes);$(SpaRoot)node_modules/** @@ -52,7 +51,6 @@ - @@ -72,18 +70,13 @@ - + wwwroot/%(StaticFiles.RecursiveDir)%(StaticFiles.Filename)%(StaticFiles.Extension) PreserveNewest true - - wwwroot/login/%(LoginFiles.RecursiveDir)%(LoginFiles.Filename)%(LoginFiles.Extension) - PreserveNewest - true - @@ -91,9 +84,8 @@ - + - diff --git a/Kyoo/Startup.cs b/Kyoo/Startup.cs index 062f62f5..e30f495e 100644 --- a/Kyoo/Startup.cs +++ b/Kyoo/Startup.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using Kyoo.Authentication; using Kyoo.Controllers; using Kyoo.Models; using Kyoo.Postgresql; @@ -46,7 +47,11 @@ namespace Kyoo _configuration = configuration; _plugins = new PluginManager(hostProvider, _configuration, loggerFactory.CreateLogger()); - _plugins.LoadPlugins(new IPlugin[] {new CoreModule(), new PostgresModule(configuration, host)}); + // TODO remove postgres from here and load it like a normal plugin. + _plugins.LoadPlugins(new IPlugin[] {new CoreModule(), + new PostgresModule(configuration, host), + new AuthenticationModule(configuration, loggerFactory, host) + }); } /// @@ -55,7 +60,7 @@ namespace Kyoo /// The service collection to fill. public void ConfigureServices(IServiceCollection services) { - string publicUrl = _configuration.GetValue("public_url"); + string publicUrl = _configuration.GetValue("publicUrl"); services.AddMvc().AddControllersAsServices(); @@ -100,7 +105,6 @@ namespace Kyoo FileExtensionContentTypeProvider contentTypeProvider = new(); contentTypeProvider.Mappings[".data"] = "application/octet-stream"; - app.UseDefaultFiles(); app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = contentTypeProvider, diff --git a/Kyoo/Views/LibraryItemApi.cs b/Kyoo/Views/LibraryItemApi.cs index 08367985..6cd81b05 100644 --- a/Kyoo/Views/LibraryItemApi.cs +++ b/Kyoo/Views/LibraryItemApi.cs @@ -25,7 +25,7 @@ namespace Kyoo.Api public LibraryItemApi(ILibraryItemRepository libraryItems, IConfiguration configuration) { _libraryItems = libraryItems; - _baseURL = configuration.GetValue("public_url").TrimEnd('/'); + _baseURL = configuration.GetValue("publicUrl").TrimEnd('/'); } [HttpGet] diff --git a/Kyoo/settings.json b/Kyoo/settings.json index 4e575d0b..e8d72e8f 100644 --- a/Kyoo/settings.json +++ b/Kyoo/settings.json @@ -1,6 +1,6 @@ { "server.urls": "http://*:5000", - "public_url": "http://localhost:5000/", + "publicUrl": "http://localhost:5000/", "database": { "postgres": {