From 2702dca8b6e7f31f64e644ec119edc09cb746bb1 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sat, 26 Oct 2019 23:58:23 +0200 Subject: [PATCH 01/44] Enable nullable reference types for Jellyfin.Server --- Jellyfin.Server/Jellyfin.Server.csproj | 3 +-- Jellyfin.Server/Program.cs | 34 ++++++++++++++++++++------ Jellyfin.Server/StartupOptions.cs | 18 +++++++------- jellyfin.ruleset | 2 ++ 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index efdb75f980..c834648a5f 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -9,9 +9,8 @@ - - latest true + enable diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e8bd0cd309..887283d2a4 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Net; @@ -21,6 +22,7 @@ using MediaBrowser.Model.Globalization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Serilog; using Serilog.Extensions.Logging; using SQLitePCL; @@ -35,7 +37,7 @@ namespace Jellyfin.Server { private static readonly CancellationTokenSource _tokenSource = new CancellationTokenSource(); private static readonly ILoggerFactory _loggerFactory = new SerilogLoggerFactory(); - private static ILogger _logger; + private static ILogger _logger = NullLogger.Instance; private static bool _restartOnShutdown; /// @@ -86,6 +88,12 @@ namespace Jellyfin.Server { var stopWatch = new Stopwatch(); stopWatch.Start(); + + // Log all uncaught exception to std error + static void UnhandledExceptionToConsole(object sender, UnhandledExceptionEventArgs e) => + Console.Error.WriteLine("Unhandled Exception\n" + e.ExceptionObject.ToString()); + AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionToConsole; + ServerApplicationPaths appPaths = CreateApplicationPaths(options); // $JELLYFIN_LOG_DIR needs to be set for the logger configuration manager @@ -97,6 +105,8 @@ namespace Jellyfin.Server _logger = _loggerFactory.CreateLogger("Main"); + // Log uncaught exceptions to the logging instead of std error + AppDomain.CurrentDomain.UnhandledException -= UnhandledExceptionToConsole; AppDomain.CurrentDomain.UnhandledException += (sender, e) => _logger.LogCritical((Exception)e.ExceptionObject, "Unhandled Exception"); @@ -129,7 +139,7 @@ namespace Jellyfin.Server _logger.LogInformation( "Jellyfin version: {Version}", - Assembly.GetEntryAssembly().GetName().Version.ToString(3)); + Assembly.GetEntryAssembly()!.GetName().Version!.ToString(3)); ApplicationHost.LogEnvironmentInfo(_logger, appPaths); @@ -361,16 +371,25 @@ namespace Jellyfin.Server private static async Task CreateConfiguration(IApplicationPaths appPaths) { + const string ResourcePath = "Jellyfin.Server.Resources.Configuration.logging.json"; string configPath = Path.Combine(appPaths.ConfigurationDirectoryPath, "logging.json"); if (!File.Exists(configPath)) { // For some reason the csproj name is used instead of the assembly name - using (Stream rscstr = typeof(Program).Assembly - .GetManifestResourceStream("Jellyfin.Server.Resources.Configuration.logging.json")) - using (Stream fstr = File.Open(configPath, FileMode.CreateNew)) + using (Stream? resource = typeof(Program).Assembly.GetManifestResourceStream(ResourcePath)) { - await rscstr.CopyToAsync(fstr).ConfigureAwait(false); + if (resource == null) + { + throw new InvalidOperationException( + string.Format( + CultureInfo.InvariantCulture, + "Invalid resource path: '{0}'", + ResourcePath)); + } + + using Stream dst = File.Open(configPath, FileMode.CreateNew); + await resource.CopyToAsync(dst).ConfigureAwait(false); } } @@ -433,7 +452,7 @@ namespace Jellyfin.Server { _logger.LogInformation("Starting new instance"); - string module = options.RestartPath; + var module = options.RestartPath; if (string.IsNullOrWhiteSpace(module)) { @@ -441,7 +460,6 @@ namespace Jellyfin.Server } string commandLineArgsString; - if (options.RestartArgs != null) { commandLineArgsString = options.RestartArgs ?? string.Empty; diff --git a/Jellyfin.Server/StartupOptions.cs b/Jellyfin.Server/StartupOptions.cs index bb0adaf630..1fb1c5af8e 100644 --- a/Jellyfin.Server/StartupOptions.cs +++ b/Jellyfin.Server/StartupOptions.cs @@ -13,39 +13,39 @@ namespace Jellyfin.Server /// /// The path to the data directory. [Option('d', "datadir", Required = false, HelpText = "Path to use for the data folder (database files, etc.).")] - public string DataDir { get; set; } + public string? DataDir { get; set; } /// /// Gets or sets the path to the web directory. /// /// The path to the web directory. [Option('w', "webdir", Required = false, HelpText = "Path to the Jellyfin web UI resources.")] - public string WebDir { get; set; } + public string? WebDir { get; set; } /// /// Gets or sets the path to the cache directory. /// /// The path to the cache directory. [Option('C', "cachedir", Required = false, HelpText = "Path to use for caching.")] - public string CacheDir { get; set; } + public string? CacheDir { get; set; } /// /// Gets or sets the path to the config directory. /// /// The path to the config directory. [Option('c', "configdir", Required = false, HelpText = "Path to use for configuration data (user settings and pictures).")] - public string ConfigDir { get; set; } + public string? ConfigDir { get; set; } /// /// Gets or sets the path to the log directory. /// /// The path to the log directory. [Option('l', "logdir", Required = false, HelpText = "Path to use for writing log files.")] - public string LogDir { get; set; } + public string? LogDir { get; set; } /// [Option("ffmpeg", Required = false, HelpText = "Path to external FFmpeg executable to use in place of default found in PATH.")] - public string FFmpegPath { get; set; } + public string? FFmpegPath { get; set; } /// [Option("service", Required = false, HelpText = "Run as headless service.")] @@ -57,14 +57,14 @@ namespace Jellyfin.Server /// [Option("package-name", Required = false, HelpText = "Used when packaging Jellyfin (example, synology).")] - public string PackageName { get; set; } + public string? PackageName { get; set; } /// [Option("restartpath", Required = false, HelpText = "Path to restart script.")] - public string RestartPath { get; set; } + public string? RestartPath { get; set; } /// [Option("restartargs", Required = false, HelpText = "Arguments for restart script.")] - public string RestartArgs { get; set; } + public string? RestartArgs { get; set; } } } diff --git a/jellyfin.ruleset b/jellyfin.ruleset index e259131b05..2c3930a28a 100644 --- a/jellyfin.ruleset +++ b/jellyfin.ruleset @@ -6,6 +6,8 @@ + + From 1258a3766f053546a7c6075503aa5b2b010d9d6c Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 29 Oct 2019 17:49:41 +0100 Subject: [PATCH 02/44] Update Jellyfin.Server/Program.cs Co-Authored-By: dkanada --- Jellyfin.Server/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 887283d2a4..4e47922522 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -89,7 +89,7 @@ namespace Jellyfin.Server var stopWatch = new Stopwatch(); stopWatch.Start(); - // Log all uncaught exception to std error + // Log all uncaught exceptions to std error static void UnhandledExceptionToConsole(object sender, UnhandledExceptionEventArgs e) => Console.Error.WriteLine("Unhandled Exception\n" + e.ExceptionObject.ToString()); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionToConsole; From e5d57bd82f9a089b7c19ea357efd2b8b34fd418b Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 12:21:54 +0200 Subject: [PATCH 03/44] Move StartupWizard to ASP.NET Web Api --- .../ApplicationHost.cs | 15 +- .../Emby.Server.Implementations.csproj | 2 + Emby.Server.Implementations/MvcRoutePrefix.cs | 48 +++++++ Jellyfin.Api/Controllers/StartupController.cs | 88 ++++++++++++ Jellyfin.Api/Jellyfin.Api.csproj | 18 +++ .../Models/Startup/StartupConfiguration.cs | 9 ++ Jellyfin.Api/Models/Startup/StartupUser.cs | 8 ++ MediaBrowser.Api/StartupWizardService.cs | 135 ------------------ MediaBrowser.sln | 11 +- 9 files changed, 192 insertions(+), 142 deletions(-) create mode 100644 Emby.Server.Implementations/MvcRoutePrefix.cs create mode 100644 Jellyfin.Api/Controllers/StartupController.cs create mode 100644 Jellyfin.Api/Jellyfin.Api.csproj create mode 100644 Jellyfin.Api/Models/Startup/StartupConfiguration.cs create mode 100644 Jellyfin.Api/Models/Startup/StartupUser.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index fef461b9ac..a9c4e1fdc9 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -108,6 +108,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -611,8 +612,6 @@ namespace Emby.Server.Implementations await RegisterResources(serviceCollection).ConfigureAwait(false); - FindParts(); - string contentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; if (string.IsNullOrEmpty(contentRoot)) { @@ -657,6 +656,14 @@ namespace Emby.Server.Implementations { services.AddResponseCompression(); services.AddHttpContextAccessor(); + services.AddMvc(opts => + { + opts.UseGeneralRoutePrefix("emby", "emby/emby", "api/v{version:apiVersion}"); + }) + .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + .AddApplicationPart(Assembly.Load("Jellyfin.Api")); + services.AddApiVersioning(opt => opt.ReportApiVersions = true); + services.TryAdd(serviceCollection); }) .Configure(app => { @@ -666,10 +673,14 @@ namespace Emby.Server.Implementations // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); + app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) .Build(); + _serviceProvider = host.Services; + FindParts(); + try { await host.StartAsync().ConfigureAwait(false); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 45607dc098..23e35f77e1 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -3,6 +3,7 @@ + @@ -25,6 +26,7 @@ + diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Emby.Server.Implementations/MvcRoutePrefix.cs new file mode 100644 index 0000000000..fb26ae09da --- /dev/null +++ b/Emby.Server.Implementations/MvcRoutePrefix.cs @@ -0,0 +1,48 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.ApplicationModels; + +namespace Emby.Server.Implementations +{ + public static class MvcRoutePrefix + { + public static void UseGeneralRoutePrefix(this MvcOptions opts, params string[] prefixes) + { + opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); + } + + internal class RoutePrefixConvention : IApplicationModelConvention + { + private readonly AttributeRouteModel[] _routePrefixes; + + public RoutePrefixConvention(IEnumerable prefixes) + { + _routePrefixes = prefixes.Select(p => new AttributeRouteModel(new RouteAttribute(p))).ToArray(); + } + + public void Apply(ApplicationModel application) + { + foreach (var controller in application.Controllers) + { + if (controller.Selectors == null) + { + continue; + } + + var newSelectors = new List(); + foreach (var selector in controller.Selectors) + { + newSelectors.AddRange(_routePrefixes.Select(routePrefix => new SelectorModel(selector) + { + AttributeRouteModel = AttributeRouteModel.CombineAttributeRouteModel(routePrefix, selector.AttributeRouteModel) + })); + } + + controller.Selectors.Clear(); + newSelectors.ForEach(selector => controller.Selectors.Add(selector)); + } + } + } + } +} diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs new file mode 100644 index 0000000000..c17b534ebf --- /dev/null +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -0,0 +1,88 @@ +using System.Linq; +using System.Threading.Tasks; +using Jellyfin.Api.Models.Startup; +using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Library; +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api.Controllers +{ + [ApiVersion("1")] + [Route("[controller]")] + public class StartupController : ControllerBase + { + private readonly IServerConfigurationManager _config; + private readonly IUserManager _userManager; + + public StartupController(IServerConfigurationManager config, IUserManager userManager) + { + _config = config; + _userManager = userManager; + } + + [HttpPost("Complete")] + public void Post() + { + _config.Configuration.IsStartupWizardCompleted = true; + _config.SetOptimalValues(); + _config.SaveConfiguration(); + } + + [HttpGet("Configuration")] + public StartupConfiguration Get() + { + var result = new StartupConfiguration + { + UICulture = _config.Configuration.UICulture, + MetadataCountryCode = _config.Configuration.MetadataCountryCode, + PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage + }; + + return result; + } + + [HttpPost("Configuration")] + public void UpdateInitial([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + { + _config.Configuration.UICulture = uiCulture; + _config.Configuration.MetadataCountryCode = metadataCountryCode; + _config.Configuration.PreferredMetadataLanguage = preferredMetadataLanguage; + _config.SaveConfiguration(); + } + + [HttpPost("RemoteAccess")] + public void Post([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) + { + _config.Configuration.EnableRemoteAccess = enableRemoteAccess; + _config.Configuration.EnableUPnP = enableAutomaticPortMapping; + _config.SaveConfiguration(); + } + + [HttpGet("User")] + public StartupUser GetUser() + { + var user = _userManager.Users.First(); + + return new StartupUser + { + Name = user.Name, + Password = user.Password + }; + } + + [HttpPost("User")] + public async Task Post([FromForm] StartupUser startupUser) + { + var user = _userManager.Users.First(); + + user.Name = startupUser.Name; + + _userManager.UpdateUser(user); + + if (!string.IsNullOrEmpty(startupUser.Password)) + { + await _userManager.ChangePassword(user, startupUser.Password).ConfigureAwait(false); + } + } + } +} diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj new file mode 100644 index 0000000000..7a7e49e302 --- /dev/null +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -0,0 +1,18 @@ + + + + netstandard2.0 + Library + + + + + + + + + + + + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs b/Jellyfin.Api/Models/Startup/StartupConfiguration.cs new file mode 100644 index 0000000000..08dd59a177 --- /dev/null +++ b/Jellyfin.Api/Models/Startup/StartupConfiguration.cs @@ -0,0 +1,9 @@ +namespace Jellyfin.Api.Models.Startup +{ + public class StartupConfiguration + { + public string UICulture { get; set; } + public string MetadataCountryCode { get; set; } + public string PreferredMetadataLanguage { get; set; } + } +} diff --git a/Jellyfin.Api/Models/Startup/StartupUser.cs b/Jellyfin.Api/Models/Startup/StartupUser.cs new file mode 100644 index 0000000000..93a09e865b --- /dev/null +++ b/Jellyfin.Api/Models/Startup/StartupUser.cs @@ -0,0 +1,8 @@ +namespace Jellyfin.Api.Models.Startup +{ + public class StartupUser + { + public string Name { get; set; } + public string Password { get; set; } + } +} diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 3a9eb7a55e..e69de29bb2 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -1,135 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using MediaBrowser.Common.Net; -using MediaBrowser.Controller; -using MediaBrowser.Controller.Configuration; -using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Controller.Net; -using MediaBrowser.Model.Services; - -namespace MediaBrowser.Api -{ - [Route("/Startup/Complete", "POST", Summary = "Reports that the startup wizard has been completed", IsHidden = true)] - public class ReportStartupWizardComplete : IReturnVoid - { - } - - [Route("/Startup/Configuration", "GET", Summary = "Gets initial server configuration", IsHidden = true)] - public class GetStartupConfiguration : IReturn - { - } - - [Route("/Startup/Configuration", "POST", Summary = "Updates initial server configuration", IsHidden = true)] - public class UpdateStartupConfiguration : StartupConfiguration, IReturnVoid - { - } - - [Route("/Startup/RemoteAccess", "POST", Summary = "Updates initial server configuration", IsHidden = true)] - public class UpdateRemoteAccessConfiguration : IReturnVoid - { - public bool EnableRemoteAccess { get; set; } - public bool EnableAutomaticPortMapping { get; set; } - } - - [Route("/Startup/User", "GET", Summary = "Gets initial user info", IsHidden = true)] - public class GetStartupUser : IReturn - { - } - - [Route("/Startup/User", "POST", Summary = "Updates initial user info", IsHidden = true)] - public class UpdateStartupUser : StartupUser - { - } - - [Authenticated(AllowBeforeStartupWizard = true, Roles = "Admin")] - public class StartupWizardService : BaseApiService - { - private readonly IServerConfigurationManager _config; - private readonly IServerApplicationHost _appHost; - private readonly IUserManager _userManager; - private readonly IMediaEncoder _mediaEncoder; - private readonly IHttpClient _httpClient; - - public StartupWizardService(IServerConfigurationManager config, IHttpClient httpClient, IServerApplicationHost appHost, IUserManager userManager, IMediaEncoder mediaEncoder) - { - _config = config; - _appHost = appHost; - _userManager = userManager; - _mediaEncoder = mediaEncoder; - _httpClient = httpClient; - } - - public void Post(ReportStartupWizardComplete request) - { - _config.Configuration.IsStartupWizardCompleted = true; - _config.SetOptimalValues(); - _config.SaveConfiguration(); - } - - public object Get(GetStartupConfiguration request) - { - var result = new StartupConfiguration - { - UICulture = _config.Configuration.UICulture, - MetadataCountryCode = _config.Configuration.MetadataCountryCode, - PreferredMetadataLanguage = _config.Configuration.PreferredMetadataLanguage - }; - - return result; - } - - public void Post(UpdateStartupConfiguration request) - { - _config.Configuration.UICulture = request.UICulture; - _config.Configuration.MetadataCountryCode = request.MetadataCountryCode; - _config.Configuration.PreferredMetadataLanguage = request.PreferredMetadataLanguage; - _config.SaveConfiguration(); - } - - public void Post(UpdateRemoteAccessConfiguration request) - { - _config.Configuration.EnableRemoteAccess = request.EnableRemoteAccess; - _config.Configuration.EnableUPnP = request.EnableAutomaticPortMapping; - _config.SaveConfiguration(); - } - - public object Get(GetStartupUser request) - { - var user = _userManager.Users.First(); - - return new StartupUser - { - Name = user.Name, - Password = user.Password - }; - } - - public async Task Post(UpdateStartupUser request) - { - var user = _userManager.Users.First(); - - user.Name = request.Name; - - _userManager.UpdateUser(user); - - if (!string.IsNullOrEmpty(request.Password)) - { - await _userManager.ChangePassword(user, request.Password).ConfigureAwait(false); - } - } - } - - public class StartupConfiguration - { - public string UICulture { get; set; } - public string MetadataCountryCode { get; set; } - public string PreferredMetadataLanguage { get; set; } - } - - public class StartupUser - { - public string Name { get; set; } - public string Password { get; set; } - } -} diff --git a/MediaBrowser.sln b/MediaBrowser.sln index 27c8c1668f..58bfb55f6f 100644 --- a/MediaBrowser.sln +++ b/MediaBrowser.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26730.3 @@ -51,6 +50,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Drawing.Skia", "Jellyfin.Drawing.Skia\Jellyfin.Drawing.Skia.csproj", "{154872D9-6C12-4007-96E3-8F70A58386CE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Api", "Jellyfin.Api\Jellyfin.Api.csproj", "{DFBEFB4C-DA19-4143-98B7-27320C7F7163}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jellyfin.Common.Tests", "tests\Jellyfin.Common.Tests\Jellyfin.Common.Tests.csproj", "{DF194677-DFD3-42AF-9F75-D44D5A416478}" @@ -89,10 +90,6 @@ Global {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.ActiveCfg = Release|Any CPU {442B5058-DCAF-4263-BB6A-F21E31120A1B}.Release|Any CPU.Build.0 = Release|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4A4402D4-E910-443B-B8FC-2C18286A2CA0}.Release|Any CPU.Build.0 = Release|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Debug|Any CPU.Build.0 = Debug|Any CPU {23499896-B135-4527-8574-C26E926EA99E}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -153,6 +150,10 @@ Global {154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.Build.0 = Debug|Any CPU {154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.ActiveCfg = Release|Any CPU {154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.Build.0 = Release|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFBEFB4C-DA19-4143-98B7-27320C7F7163}.Release|Any CPU.Build.0 = Release|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Debug|Any CPU.Build.0 = Debug|Any CPU {DF194677-DFD3-42AF-9F75-D44D5A416478}.Release|Any CPU.ActiveCfg = Release|Any CPU From c011fa2ea80a5f7f994649e6257bccf572f299e1 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 18:26:23 +0200 Subject: [PATCH 04/44] Remove old instantiation of serviceProvider in app host --- Emby.Server.Implementations/ApplicationHost.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index a9c4e1fdc9..11ee6d2d20 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -663,6 +663,7 @@ namespace Emby.Server.Implementations .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddApplicationPart(Assembly.Load("Jellyfin.Api")); services.AddApiVersioning(opt => opt.ReportApiVersions = true); + // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => @@ -929,8 +930,6 @@ namespace Emby.Server.Implementations ((UserDataManager)UserDataManager).Repository = userDataRepo; ItemRepository.Initialize(userDataRepo, UserManager); ((LibraryManager)LibraryManager).ItemRepository = ItemRepository; - - _serviceProvider = serviceCollection.BuildServiceProvider(); } public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths) From 05b7e2280843f25e48c2300b135f171aee0a54ea Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 2 Jul 2019 20:17:00 +0200 Subject: [PATCH 05/44] Add SwaggerUI --- .../ApplicationHost.cs | 27 +++++++++++++++++++ .../Emby.Server.Implementations.csproj | 4 ++- Jellyfin.Api/Controllers/StartupController.cs | 5 ++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 11ee6d2d20..3d2d61225e 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -113,7 +113,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; using ServiceStack; +using Swashbuckle.AspNetCore.SwaggerGen; using OperatingSystem = MediaBrowser.Common.System.OperatingSystem; namespace Emby.Server.Implementations @@ -663,11 +665,36 @@ namespace Emby.Server.Implementations .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddApplicationPart(Assembly.Load("Jellyfin.Api")); services.AddApiVersioning(opt => opt.ReportApiVersions = true); + services.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); + c.DocInclusionPredicate((docName, apiDesc) => + { + if (!apiDesc.TryGetMethodInfo(out var methodInfo)) + { + return false; + } + + // A bit of a hack to make Swagger pick the versioned endpoints instead of the legacy emby endpoints + return methodInfo.DeclaringType?.BaseType == typeof(ControllerBase) && + apiDesc.RelativePath.Contains("api/v"); + }); + }); + // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => { + app.UseSwagger(); + + // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), + // specifying the Swagger JSON endpoint. + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); + }); + app.UseWebSockets(); app.UseResponseCompression(); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 23e35f77e1..26301b379e 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -1,4 +1,4 @@ - + @@ -21,6 +21,7 @@ + @@ -37,6 +38,7 @@ + diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index c17b534ebf..45e4cd5ac8 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -8,7 +8,6 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { [ApiVersion("1")] - [Route("[controller]")] public class StartupController : ControllerBase { private readonly IServerConfigurationManager _config; @@ -21,7 +20,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Complete")] - public void Post() + public void CompleteWizard() { _config.Configuration.IsStartupWizardCompleted = true; _config.SetOptimalValues(); @@ -71,7 +70,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("User")] - public async Task Post([FromForm] StartupUser startupUser) + public async Task UpdateUser([FromForm] StartupUser startupUser) { var user = _userManager.Users.First(); From 3f651de24c76f9980fac690e51fa93b3d1163f72 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 16:31:02 +0100 Subject: [PATCH 06/44] Add authentication and remove versioning --- .../ApplicationHost.cs | 58 ++++++++++++++----- .../Emby.Server.Implementations.csproj | 5 +- .../HttpServer/Security/AuthService.cs | 17 +++++- Emby.Server.Implementations/MvcRoutePrefix.cs | 2 +- .../Auth/CustomAuthenticationHandler.cs | 53 +++++++++++++++++ .../FirstTimeSetupOrElevatedHandler.cs | 35 +++++++++++ .../FirstTimeSetupOrElevatedRequirement.cs | 8 +++ .../RequiresElevationHandler.cs | 18 ++++++ .../RequiresElevationRequirement.cs | 9 +++ Jellyfin.Api/BaseJellyfinApiController.cs | 11 ++++ Jellyfin.Api/Controllers/StartupController.cs | 25 ++++---- Jellyfin.Api/Jellyfin.Api.csproj | 34 +++++------ ...guration.cs => StartupConfigurationDto.cs} | 2 +- .../{StartupUser.cs => StartupUserDto.cs} | 2 +- MediaBrowser.Controller/Net/IAuthService.cs | 3 + 15 files changed, 232 insertions(+), 50 deletions(-) create mode 100644 Jellyfin.Api/Auth/CustomAuthenticationHandler.cs create mode 100644 Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs create mode 100644 Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs create mode 100644 Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs create mode 100644 Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs create mode 100644 Jellyfin.Api/BaseJellyfinApiController.cs rename Jellyfin.Api/Models/Startup/{StartupConfiguration.cs => StartupConfigurationDto.cs} (84%) rename Jellyfin.Api/Models/Startup/{StartupUser.cs => StartupUserDto.cs} (81%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3d2d61225e..9227ef61ba 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,6 +47,10 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; +using Jellyfin.Api.Auth; +using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; +using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Controllers; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -104,11 +108,14 @@ using MediaBrowser.Providers.Subtitles; using MediaBrowser.Providers.TV.TheTVDB; using MediaBrowser.WebDashboard.Api; using MediaBrowser.XbmcMetadata.Providers; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -660,25 +667,45 @@ namespace Emby.Server.Implementations services.AddHttpContextAccessor(); services.AddMvc(opts => { - opts.UseGeneralRoutePrefix("emby", "emby/emby", "api/v{version:apiVersion}"); + var policy = new AuthorizationPolicyBuilder() + .RequireAuthenticatedUser() + .Build(); + opts.Filters.Add(new AuthorizeFilter(policy)); + opts.EnableEndpointRouting = false; + opts.UseGeneralRoutePrefix(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .AddApplicationPart(Assembly.Load("Jellyfin.Api")); - services.AddApiVersioning(opt => opt.ReportApiVersions = true); + .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) // Clear app parts to avoid other assemblies being picked up + .AddApplicationPart(typeof(StartupController).Assembly) + .AddControllersAsServices(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); - c.DocInclusionPredicate((docName, apiDesc) => - { - if (!apiDesc.TryGetMethodInfo(out var methodInfo)) - { - return false; - } + }); - // A bit of a hack to make Swagger pick the versioned endpoints instead of the legacy emby endpoints - return methodInfo.DeclaringType?.BaseType == typeof(ControllerBase) && - apiDesc.RelativePath.Contains("api/v"); - }); + services.AddSingleton(); + services.AddSingleton(); + + // configure custom legacy authentication + services.AddAuthentication("CustomAuthentication") + .AddScheme("CustomAuthentication", null); + + services.AddAuthorizationCore(options => + { + options.AddPolicy( + "RequiresElevation", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new RequiresElevationRequirement()); + }); + options.AddPolicy( + "FirstTimeSetupOrElevated", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); + }); }); // Merge the external ServiceCollection into ASP.NET DI @@ -686,6 +713,7 @@ namespace Emby.Server.Implementations }) .Configure(app => { + app.UseDeveloperExceptionPage(); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), @@ -698,9 +726,9 @@ namespace Emby.Server.Implementations app.UseWebSockets(); app.UseResponseCompression(); - // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); + //app.UseAuthentication(); app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) @@ -938,7 +966,7 @@ namespace Emby.Server.Implementations serviceCollection.AddSingleton(authContext); serviceCollection.AddSingleton(new SessionContext(UserManager, authContext, SessionManager)); - AuthService = new AuthService(authContext, ServerConfigurationManager, SessionManager, NetworkManager); + AuthService = new AuthService(LoggerFactory, authContext, ServerConfigurationManager, SessionManager, NetworkManager); serviceCollection.AddSingleton(AuthService); SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 26301b379e..e7164342c3 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,6 +21,9 @@ + + + @@ -38,7 +41,7 @@ - + diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 93a61fe67a..81dab83d5e 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Emby.Server.Implementations.SocketSharp; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities; @@ -7,22 +8,27 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Security; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.HttpServer.Security { public class AuthService : IAuthService { + private readonly ILogger _logger; private readonly IAuthorizationContext _authorizationContext; private readonly ISessionManager _sessionManager; private readonly IServerConfigurationManager _config; private readonly INetworkManager _networkManager; public AuthService( + ILoggerFactory loggerFactory, IAuthorizationContext authorizationContext, IServerConfigurationManager config, ISessionManager sessionManager, INetworkManager networkManager) { + _logger = loggerFactory.CreateLogger(); _authorizationContext = authorizationContext; _config = config; _sessionManager = sessionManager; @@ -34,7 +40,14 @@ namespace Emby.Server.Implementations.HttpServer.Security ValidateUser(request, authAttribtues); } - private void ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues) + public User Authenticate(HttpRequest request, IAuthenticationAttributes authAttributes) + { + var req = new WebSocketSharpRequest(request, null, request.Path, _logger); + var user = ValidateUser(req, authAttributes); + return user; + } + + private User ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues) { // This code is executed before the service var auth = _authorizationContext.GetAuthorizationInfo(request); @@ -81,6 +94,8 @@ namespace Emby.Server.Implementations.HttpServer.Security request.RemoteIp, user); } + + return user; } private void ValidateUserAccess( diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Emby.Server.Implementations/MvcRoutePrefix.cs index fb26ae09da..974a2a8852 100644 --- a/Emby.Server.Implementations/MvcRoutePrefix.cs +++ b/Emby.Server.Implementations/MvcRoutePrefix.cs @@ -12,7 +12,7 @@ namespace Emby.Server.Implementations opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); } - internal class RoutePrefixConvention : IApplicationModelConvention + private class RoutePrefixConvention : IApplicationModelConvention { private readonly AttributeRouteModel[] _routePrefixes; diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs new file mode 100644 index 0000000000..bb6192b03d --- /dev/null +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -0,0 +1,53 @@ +using System.Security.Claims; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using MediaBrowser.Controller.Net; +using Microsoft.AspNetCore.Authentication; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace Jellyfin.Api.Auth +{ + public class CustomAuthenticationHandler : AuthenticationHandler + { + private readonly IAuthService _authService; + + public CustomAuthenticationHandler( + IAuthService authService, + IOptionsMonitor options, + ILoggerFactory logger, + UrlEncoder encoder, + ISystemClock clock) : base(options, logger, encoder, clock) + { + _authService = authService; + } + + protected override Task HandleAuthenticateAsync() + { + var authenticatedAttribute = new AuthenticatedAttribute(); + try + { + var user = _authService.Authenticate(Request, authenticatedAttribute); + if (user == null) + { + return Task.FromResult(AuthenticateResult.Fail("Invalid user")); + } + + var claims = new[] + { + new Claim(ClaimTypes.Name, user.Name), + new Claim(ClaimTypes.Role, user.Policy.IsAdministrator ? "Administrator" : "User"), + }; + var identity = new ClaimsIdentity(claims, Scheme.Name); + var principal = new ClaimsPrincipal(identity); + var ticket = new AuthenticationTicket(principal, Scheme.Name); + + return Task.FromResult(AuthenticateResult.Success(ticket)); + } + catch (SecurityException ex) + { + return Task.FromResult(AuthenticateResult.Fail(ex)); + } + } + } +} diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs new file mode 100644 index 0000000000..73925cd616 --- /dev/null +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -0,0 +1,35 @@ +using System.Threading.Tasks; +using MediaBrowser.Common.Configuration; +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy +{ + public class FirstTimeSetupOrElevatedHandler : AuthorizationHandler + { + private readonly IConfigurationManager _configurationManager; + + public FirstTimeSetupOrElevatedHandler(IConfigurationManager configurationManager) + { + _configurationManager = configurationManager; + } + + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) + { + if (!_configurationManager.CommonConfiguration.IsStartupWizardCompleted) + { + context.Succeed(firstTimeSetupOrElevatedRequirement); + } + else if (context.User.IsInRole("Administrator")) + { + // TODO user role enum + context.Succeed(firstTimeSetupOrElevatedRequirement); + } + else + { + context.Fail(); + } + + return Task.CompletedTask; + } + } +} diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs new file mode 100644 index 0000000000..42436c870d --- /dev/null +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy +{ + public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement + { + } +} diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs new file mode 100644 index 0000000000..6948274582 --- /dev/null +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.RequiresElevationPolicy +{ + public class RequiresElevationHandler : AuthorizationHandler + { + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) + { + if (context.User.IsInRole("Administrator")) + { + context.Succeed(requirement); + } + + return Task.CompletedTask; + } + } +} diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs new file mode 100644 index 0000000000..dd51cd3c20 --- /dev/null +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs @@ -0,0 +1,9 @@ +using Microsoft.AspNetCore.Authorization; + +namespace Jellyfin.Api.Auth.RequiresElevationPolicy +{ + public class RequiresElevationRequirement : IAuthorizationRequirement + { + + } +} diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.cs new file mode 100644 index 0000000000..796a8039af --- /dev/null +++ b/Jellyfin.Api/BaseJellyfinApiController.cs @@ -0,0 +1,11 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Jellyfin.Api +{ + [ApiController] + [Route("[controller]")] + public class BaseJellyfinApiController : ControllerBase + { + + } +} diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 45e4cd5ac8..fb61b8d0b3 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -3,12 +3,13 @@ using System.Threading.Tasks; using Jellyfin.Api.Models.Startup; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { - [ApiVersion("1")] - public class StartupController : ControllerBase + [Authorize(Policy = "FirstTimeSetupOrElevated")] + public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; private readonly IUserManager _userManager; @@ -28,9 +29,9 @@ namespace Jellyfin.Api.Controllers } [HttpGet("Configuration")] - public StartupConfiguration Get() + public StartupConfigurationDto GetStartupConfiguration() { - var result = new StartupConfiguration + var result = new StartupConfigurationDto { UICulture = _config.Configuration.UICulture, MetadataCountryCode = _config.Configuration.MetadataCountryCode, @@ -41,7 +42,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Configuration")] - public void UpdateInitial([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + public void UpdateInitialConfiguration([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) { _config.Configuration.UICulture = uiCulture; _config.Configuration.MetadataCountryCode = metadataCountryCode; @@ -50,7 +51,7 @@ namespace Jellyfin.Api.Controllers } [HttpPost("RemoteAccess")] - public void Post([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) + public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) { _config.Configuration.EnableRemoteAccess = enableRemoteAccess; _config.Configuration.EnableUPnP = enableAutomaticPortMapping; @@ -58,11 +59,11 @@ namespace Jellyfin.Api.Controllers } [HttpGet("User")] - public StartupUser GetUser() + public StartupUserDto GetUser() { var user = _userManager.Users.First(); - return new StartupUser + return new StartupUserDto { Name = user.Name, Password = user.Password @@ -70,17 +71,17 @@ namespace Jellyfin.Api.Controllers } [HttpPost("User")] - public async Task UpdateUser([FromForm] StartupUser startupUser) + public async Task UpdateUser([FromForm] StartupUserDto startupUserDto) { var user = _userManager.Users.First(); - user.Name = startupUser.Name; + user.Name = startupUserDto.Name; _userManager.UpdateUser(user); - if (!string.IsNullOrEmpty(startupUser.Password)) + if (!string.IsNullOrEmpty(startupUserDto.Password)) { - await _userManager.ChangePassword(user, startupUser.Password).ConfigureAwait(false); + await _userManager.ChangePassword(user, startupUserDto.Password).ConfigureAwait(false); } } } diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 7a7e49e302..647004cb68 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -1,18 +1,16 @@ - - - - netstandard2.0 - Library - - - - - - - - - - - - - + + + + netstandard2.1 + + + + + + + + + + + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs similarity index 84% rename from Jellyfin.Api/Models/Startup/StartupConfiguration.cs rename to Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs index 08dd59a177..769d2e1bb6 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfiguration.cs +++ b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs @@ -1,6 +1,6 @@ namespace Jellyfin.Api.Models.Startup { - public class StartupConfiguration + public class StartupConfigurationDto { public string UICulture { get; set; } public string MetadataCountryCode { get; set; } diff --git a/Jellyfin.Api/Models/Startup/StartupUser.cs b/Jellyfin.Api/Models/Startup/StartupUserDto.cs similarity index 81% rename from Jellyfin.Api/Models/Startup/StartupUser.cs rename to Jellyfin.Api/Models/Startup/StartupUserDto.cs index 93a09e865b..c7c2e8cb04 100644 --- a/Jellyfin.Api/Models/Startup/StartupUser.cs +++ b/Jellyfin.Api/Models/Startup/StartupUserDto.cs @@ -1,6 +1,6 @@ namespace Jellyfin.Api.Models.Startup { - public class StartupUser + public class StartupUserDto { public string Name { get; set; } public string Password { get; set; } diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs index 142f1d91c3..4c9120e0c9 100644 --- a/MediaBrowser.Controller/Net/IAuthService.cs +++ b/MediaBrowser.Controller/Net/IAuthService.cs @@ -1,9 +1,12 @@ +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Services; +using Microsoft.AspNetCore.Http; namespace MediaBrowser.Controller.Net { public interface IAuthService { void Authenticate(IRequest request, IAuthenticationAttributes authAttribtues); + User Authenticate(HttpRequest request, IAuthenticationAttributes authAttribtues); } } From 706739dbe6c3f22584cf18115b161a9c1882093c Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 19:43:30 +0100 Subject: [PATCH 07/44] Move API stuff to the api project --- .../ApplicationHost.cs | 69 +++--------------- .../Emby.Server.Implementations.csproj | 5 -- .../ApiApplicationBuilderExtensions.cs | 19 +++++ .../ApiServiceCollectionExtensions.cs | 72 +++++++++++++++++++ Jellyfin.Api/Jellyfin.Api.csproj | 2 + .../MvcRoutePrefix.cs | 0 6 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs create mode 100644 Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs rename {Emby.Server.Implementations => Jellyfin.Api}/MvcRoutePrefix.cs (100%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 9227ef61ba..c6cdd4786b 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,10 +47,7 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; -using Jellyfin.Api.Auth; -using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; -using Jellyfin.Api.Auth.RequiresElevationPolicy; -using Jellyfin.Api.Controllers; +using Jellyfin.Api.Extensions; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -92,7 +89,6 @@ using MediaBrowser.Model.Cryptography; using MediaBrowser.Model.Diagnostics; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Events; -using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Globalization; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; @@ -108,21 +104,15 @@ using MediaBrowser.Providers.Subtitles; using MediaBrowser.Providers.TV.TheTVDB; using MediaBrowser.WebDashboard.Api; using MediaBrowser.XbmcMetadata.Providers; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Models; -using ServiceStack; -using Swashbuckle.AspNetCore.SwaggerGen; using OperatingSystem = MediaBrowser.Common.System.OperatingSystem; namespace Emby.Server.Implementations @@ -665,70 +655,29 @@ namespace Emby.Server.Implementations { services.AddResponseCompression(); services.AddHttpContextAccessor(); - services.AddMvc(opts => - { - var policy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - opts.Filters.Add(new AuthorizeFilter(policy)); - opts.EnableEndpointRouting = false; - opts.UseGeneralRoutePrefix(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) // Clear app parts to avoid other assemblies being picked up - .AddApplicationPart(typeof(StartupController).Assembly) - .AddControllersAsServices(); - services.AddSwaggerGen(c => - { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); - }); + services.AddJellyfinApi(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - services.AddSingleton(); - services.AddSingleton(); + services.AddJellyfinApiSwagger(); // configure custom legacy authentication - services.AddAuthentication("CustomAuthentication") - .AddScheme("CustomAuthentication", null); + services.AddCustomAuthentication(); - services.AddAuthorizationCore(options => - { - options.AddPolicy( - "RequiresElevation", - policy => - { - policy.AddAuthenticationSchemes("CustomAuthentication"); - policy.AddRequirements(new RequiresElevationRequirement()); - }); - options.AddPolicy( - "FirstTimeSetupOrElevated", - policy => - { - policy.AddAuthenticationSchemes("CustomAuthentication"); - policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); - }); - }); + services.AddJellyfinApiAuthorization(); // Merge the external ServiceCollection into ASP.NET DI services.TryAdd(serviceCollection); }) .Configure(app => { - app.UseDeveloperExceptionPage(); - app.UseSwagger(); - - // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), - // specifying the Swagger JSON endpoint. - app.UseSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); - }); - app.UseWebSockets(); app.UseResponseCompression(); + // TODO app.UseMiddleware(); app.Use(ExecuteWebsocketHandlerAsync); - //app.UseAuthentication(); + + // TODO use when old API is removed: app.UseAuthentication(); + app.UseJellyfinApiSwagger(); app.UseMvc(); app.Use(ExecuteHttpHandlerAsync); }) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index e7164342c3..6fc48a2e19 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,16 +21,12 @@ - - - - @@ -41,7 +37,6 @@ - diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs new file mode 100644 index 0000000000..18442bf272 --- /dev/null +++ b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Builder; + +namespace Jellyfin.Api.Extensions +{ + public static class ApiApplicationBuilderExtensions + { + public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder) + { + applicationBuilder.UseSwagger(); + + // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), + // specifying the Swagger JSON endpoint. + return applicationBuilder.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "Jellyfin API V1"); + }); + } + } +} diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs new file mode 100644 index 0000000000..1c682f8e43 --- /dev/null +++ b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs @@ -0,0 +1,72 @@ +using Emby.Server.Implementations; +using Jellyfin.Api.Auth; +using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; +using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Controllers; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Authorization; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.OpenApi.Models; + +namespace Jellyfin.Api.Extensions +{ + public static class ApiServiceCollectionExtensions + { + public static IServiceCollection AddJellyfinApiAuthorization(this IServiceCollection serviceCollection) + { + serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); + return serviceCollection.AddAuthorizationCore(options => + { + options.AddPolicy( + "RequiresElevation", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new RequiresElevationRequirement()); + }); + options.AddPolicy( + "FirstTimeSetupOrElevated", + policy => + { + policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); + }); + }); + } + + public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) + { + return serviceCollection.AddAuthentication("CustomAuthentication") + .AddScheme("CustomAuthentication", null); + } + + public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl) + { + return serviceCollection.AddMvc(opts => + { + var policy = new AuthorizationPolicyBuilder() + .RequireAuthenticatedUser() + .Build(); + opts.Filters.Add(new AuthorizeFilter(policy)); + opts.EnableEndpointRouting = false; + opts.UseGeneralRoutePrefix(baseUrl); + }) + .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + // Clear app parts to avoid other assemblies being picked up + .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) + .AddApplicationPart(typeof(StartupController).Assembly) + .AddControllersAsServices(); + } + + public static IServiceCollection AddJellyfinApiSwagger(this IServiceCollection serviceCollection) + { + return serviceCollection.AddSwaggerGen(c => + { + c.SwaggerDoc("v1", new OpenApiInfo { Title = "Jellyfin API", Version = "v1" }); + }); + } + } +} diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 647004cb68..d77861cc4a 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -6,7 +6,9 @@ + + diff --git a/Emby.Server.Implementations/MvcRoutePrefix.cs b/Jellyfin.Api/MvcRoutePrefix.cs similarity index 100% rename from Emby.Server.Implementations/MvcRoutePrefix.cs rename to Jellyfin.Api/MvcRoutePrefix.cs From c9669a0d21f37fe06a8838c001a6f93505ba549b Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 19:59:45 +0100 Subject: [PATCH 08/44] Split a long line --- Jellyfin.Api/Controllers/StartupController.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index fb61b8d0b3..271745e057 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -42,7 +42,10 @@ namespace Jellyfin.Api.Controllers } [HttpPost("Configuration")] - public void UpdateInitialConfiguration([FromForm] string uiCulture, [FromForm] string metadataCountryCode, [FromForm] string preferredMetadataLanguage) + public void UpdateInitialConfiguration( + [FromForm] string uiCulture, + [FromForm] string metadataCountryCode, + [FromForm] string preferredMetadataLanguage) { _config.Configuration.UICulture = uiCulture; _config.Configuration.MetadataCountryCode = metadataCountryCode; From c2cdbc909ba8371261bb88b5dd313262be755fa3 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 20:31:17 +0100 Subject: [PATCH 09/44] Add style rules and fix it all --- .../Auth/CustomAuthenticationHandler.cs | 17 ++++++++- .../FirstTimeSetupOrElevatedHandler.cs | 14 +++++-- .../FirstTimeSetupOrElevatedRequirement.cs | 3 ++ .../RequiresElevationHandler.cs | 7 +++- .../RequiresElevationRequirement.cs | 4 +- Jellyfin.Api/BaseJellyfinApiController.cs | 4 +- Jellyfin.Api/Controllers/StartupController.cs | 37 ++++++++++++++++++- Jellyfin.Api/Enums/UserRole.cs | 23 ++++++++++++ .../ApiApplicationBuilderExtensions.cs | 8 ++++ .../ApiServiceCollectionExtensions.cs | 26 ++++++++++++- Jellyfin.Api/Jellyfin.Api.csproj | 14 +++++++ .../Models/Startup/StartupConfigurationDto.cs | 14 +++++++ Jellyfin.Api/Models/Startup/StartupUserDto.cs | 10 +++++ Jellyfin.Api/MvcRoutePrefix.cs | 10 ++++- 14 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 Jellyfin.Api/Enums/UserRole.cs diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index bb6192b03d..a753d60838 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -1,6 +1,7 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; +using Jellyfin.Api.Enums; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Logging; @@ -8,10 +9,21 @@ using Microsoft.Extensions.Options; namespace Jellyfin.Api.Auth { + /// + /// Custom authentication handler wrapping the legacy authentication. + /// public class CustomAuthenticationHandler : AuthenticationHandler { private readonly IAuthService _authService; + /// + /// Initializes a new instance of the class. + /// + /// The jellyfin authentication service. + /// Options monitor. + /// The logger. + /// The url encoder. + /// The system clock. public CustomAuthenticationHandler( IAuthService authService, IOptionsMonitor options, @@ -22,6 +34,7 @@ namespace Jellyfin.Api.Auth _authService = authService; } + /// protected override Task HandleAuthenticateAsync() { var authenticatedAttribute = new AuthenticatedAttribute(); @@ -36,7 +49,9 @@ namespace Jellyfin.Api.Auth var claims = new[] { new Claim(ClaimTypes.Name, user.Name), - new Claim(ClaimTypes.Role, user.Policy.IsAdministrator ? "Administrator" : "User"), + new Claim( + ClaimTypes.Role, + value: user.Policy.IsAdministrator ? UserRole.Administrator.ToString() : UserRole.User.ToString()) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index 73925cd616..f07e568dea 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -1,27 +1,35 @@ using System.Threading.Tasks; +using Jellyfin.Api.Enums; using MediaBrowser.Common.Configuration; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { + /// + /// Authorization handler for requiring first time setup or elevated privileges. + /// public class FirstTimeSetupOrElevatedHandler : AuthorizationHandler { private readonly IConfigurationManager _configurationManager; + /// + /// Initializes a new instance of the class. + /// + /// The jellyfin configuration manager. public FirstTimeSetupOrElevatedHandler(IConfigurationManager configurationManager) { _configurationManager = configurationManager; } - protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) + /// + protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, FirstTimeSetupOrElevatedRequirement firstTimeSetupOrElevatedRequirement) { if (!_configurationManager.CommonConfiguration.IsStartupWizardCompleted) { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole("Administrator")) + else if (context.User.IsInRole(UserRole.Administrator.ToString())) { - // TODO user role enum context.Succeed(firstTimeSetupOrElevatedRequirement); } else diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs index 42436c870d..a590155420 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -2,6 +2,9 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { + /// + /// The authorization requirement, requiring first time setup or elevated privileges, for the authorization handler. + /// public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement { } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 6948274582..8674f3e262 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -1,13 +1,18 @@ using System.Threading.Tasks; +using Jellyfin.Api.Enums; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy { + /// + /// Authorization handler for requiring elevated privileges. + /// public class RequiresElevationHandler : AuthorizationHandler { + /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole("Administrator")) + if (context.User.IsInRole(UserRole.Administrator.ToString())) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs index dd51cd3c20..cfff1cc0c5 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationRequirement.cs @@ -2,8 +2,10 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy { + /// + /// The authorization requirement for requiring elevated privileges in the authorization handler. + /// public class RequiresElevationRequirement : IAuthorizationRequirement { - } } diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.cs index 796a8039af..1f4508e6cb 100644 --- a/Jellyfin.Api/BaseJellyfinApiController.cs +++ b/Jellyfin.Api/BaseJellyfinApiController.cs @@ -2,10 +2,12 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api { + /// + /// Base api controller for the API setting a default route. + /// [ApiController] [Route("[controller]")] public class BaseJellyfinApiController : ControllerBase { - } } diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 271745e057..0e7d17a27f 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -8,18 +8,29 @@ using Microsoft.AspNetCore.Mvc; namespace Jellyfin.Api.Controllers { + /// + /// The startup wizard controller. + /// [Authorize(Policy = "FirstTimeSetupOrElevated")] public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; private readonly IUserManager _userManager; + /// + /// Initializes a new instance of the class. + /// + /// The server configuration manager. + /// The user manager. public StartupController(IServerConfigurationManager config, IUserManager userManager) { _config = config; _userManager = userManager; } + /// + /// Api endpoint for completing the startup wizard. + /// [HttpPost("Complete")] public void CompleteWizard() { @@ -28,6 +39,10 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for getting the initial startup wizard configuration. + /// + /// The initial startup wizard configuration. [HttpGet("Configuration")] public StartupConfigurationDto GetStartupConfiguration() { @@ -41,6 +56,12 @@ namespace Jellyfin.Api.Controllers return result; } + /// + /// Endpoint for updating the initial startup wizard configuration. + /// + /// The UI language culture. + /// The metadata country code. + /// The preferred language for metadata. [HttpPost("Configuration")] public void UpdateInitialConfiguration( [FromForm] string uiCulture, @@ -53,6 +74,11 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for (dis)allowing remote access and UPnP. + /// + /// Enable remote access. + /// Enable UPnP. [HttpPost("RemoteAccess")] public void SetRemoteAccess([FromForm] bool enableRemoteAccess, [FromForm] bool enableAutomaticPortMapping) { @@ -61,8 +87,12 @@ namespace Jellyfin.Api.Controllers _config.SaveConfiguration(); } + /// + /// Endpoint for returning the first user. + /// + /// The first user. [HttpGet("User")] - public StartupUserDto GetUser() + public StartupUserDto GetFirstUser() { var user = _userManager.Users.First(); @@ -73,6 +103,11 @@ namespace Jellyfin.Api.Controllers }; } + /// + /// Endpoint for updating the user name and password. + /// + /// The DTO containing username and password. + /// The async task. [HttpPost("User")] public async Task UpdateUser([FromForm] StartupUserDto startupUserDto) { diff --git a/Jellyfin.Api/Enums/UserRole.cs b/Jellyfin.Api/Enums/UserRole.cs new file mode 100644 index 0000000000..05826d9f41 --- /dev/null +++ b/Jellyfin.Api/Enums/UserRole.cs @@ -0,0 +1,23 @@ +namespace Jellyfin.Api.Enums +{ + /// + /// Enum for user roles used in the authentication and authorization for the API. + /// + public enum UserRole + { + /// + /// Guest user. + /// + Guest = 0, + + /// + /// Regular user with no special privileges. + /// + User = 1, + + /// + /// Administrator user with elevated privileges. + /// + Administrator = 2 + } +} diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs index 18442bf272..f70466ebec 100644 --- a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs +++ b/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs @@ -2,8 +2,16 @@ using Microsoft.AspNetCore.Builder; namespace Jellyfin.Api.Extensions { + /// + /// Extensions for adding API specific functionality to the application pipeline. + /// public static class ApiApplicationBuilderExtensions { + /// + /// Adds swagger and swagger UI to the application pipeline. + /// + /// The application builder. + /// The updated application builder. public static IApplicationBuilder UseJellyfinApiSwagger(this IApplicationBuilder applicationBuilder) { applicationBuilder.UseSwagger(); diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs index 1c682f8e43..38f5f6d390 100644 --- a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs @@ -1,4 +1,3 @@ -using Emby.Server.Implementations; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; @@ -12,8 +11,16 @@ using Microsoft.OpenApi.Models; namespace Jellyfin.Api.Extensions { + /// + /// API specific extensions for the service collection. + /// public static class ApiServiceCollectionExtensions { + /// + /// Adds jellyfin API authorization policies to the DI container. + /// + /// The service collection. + /// The updated service collection. public static IServiceCollection AddJellyfinApiAuthorization(this IServiceCollection serviceCollection) { serviceCollection.AddSingleton(); @@ -37,12 +44,23 @@ namespace Jellyfin.Api.Extensions }); } + /// + /// Adds custom legacy authentication to the service collection. + /// + /// The service collection. + /// The updated service collection. public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) { return serviceCollection.AddAuthentication("CustomAuthentication") .AddScheme("CustomAuthentication", null); } + /// + /// Extension method for adding the jellyfin API to the service collection. + /// + /// The service collection. + /// The base url for the API. + /// The MVC builder. public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl) { return serviceCollection.AddMvc(opts => @@ -55,12 +73,18 @@ namespace Jellyfin.Api.Extensions opts.UseGeneralRoutePrefix(baseUrl); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) + // Clear app parts to avoid other assemblies being picked up .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) .AddApplicationPart(typeof(StartupController).Assembly) .AddControllersAsServices(); } + /// + /// Adds Swagger to the service collection. + /// + /// The service collection. + /// The updated service collection. public static IServiceCollection AddJellyfinApiSwagger(this IServiceCollection serviceCollection) { return serviceCollection.AddSwaggerGen(c => diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index d77861cc4a..1cc23c07b4 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -2,6 +2,8 @@ netstandard2.1 + true + true @@ -15,4 +17,16 @@ + + + + + + + + + + ../jellyfin.ruleset + + diff --git a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs index 769d2e1bb6..dac15e412c 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs +++ b/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs @@ -1,9 +1,23 @@ namespace Jellyfin.Api.Models.Startup { + /// + /// The startup configuration DTO. + /// public class StartupConfigurationDto { + /// + /// Gets or sets UI language culture. + /// public string UICulture { get; set; } + + /// + /// Gets or sets the metadata country code. + /// public string MetadataCountryCode { get; set; } + + /// + /// Gets or sets the preferred language for the metadata. + /// public string PreferredMetadataLanguage { get; set; } } } diff --git a/Jellyfin.Api/Models/Startup/StartupUserDto.cs b/Jellyfin.Api/Models/Startup/StartupUserDto.cs index c7c2e8cb04..7e890d76a0 100644 --- a/Jellyfin.Api/Models/Startup/StartupUserDto.cs +++ b/Jellyfin.Api/Models/Startup/StartupUserDto.cs @@ -1,8 +1,18 @@ namespace Jellyfin.Api.Models.Startup { + /// + /// The startup user DTO. + /// public class StartupUserDto { + /// + /// Gets or sets the username. + /// public string Name { get; set; } + + /// + /// Gets or sets the user's password. + /// public string Password { get; set; } } } diff --git a/Jellyfin.Api/MvcRoutePrefix.cs b/Jellyfin.Api/MvcRoutePrefix.cs index 974a2a8852..e009730947 100644 --- a/Jellyfin.Api/MvcRoutePrefix.cs +++ b/Jellyfin.Api/MvcRoutePrefix.cs @@ -3,10 +3,18 @@ using System.Linq; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; -namespace Emby.Server.Implementations +namespace Jellyfin.Api { + /// + /// Route prefixing for ASP.NET MVC. + /// public static class MvcRoutePrefix { + /// + /// Adds route prefixes to the MVC conventions. + /// + /// The MVC options. + /// The list of prefixes. public static void UseGeneralRoutePrefix(this MvcOptions opts, params string[] prefixes) { opts.Conventions.Insert(0, new RoutePrefixConvention(prefixes)); From 111b46599a66e81a8449e777cccc516c06b7548d Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sat, 23 Nov 2019 20:46:01 +0100 Subject: [PATCH 10/44] Remove unused reference --- Emby.Server.Implementations/Emby.Server.Implementations.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 6fc48a2e19..9f524a4afd 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -21,7 +21,6 @@ - From dbda76e84252d11c31d4d3f07d5e810ac2096d81 Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 24 Nov 2019 21:27:43 +0900 Subject: [PATCH 11/44] Update readme --- README.md | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 07d49fc517..268b28db7f 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,16 @@ ---

-Logo banner +Logo Banner

GPL 2.0 License Current Release -Translation status -Azure DevOps builds +Translation Status +Azure Builds Docker Pull Count
Donate -Submit and vote on feature requests +Submit Feature Requests Discuss on our Forum Chat on Matrix Join our Subreddit @@ -23,23 +23,22 @@ Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. It is an alternative to the proprietary Emby and Plex, to provide media from a dedicated server to end-user devices via multiple apps. Jellyfin is descended from Emby's 3.5.2 release and ported to the .NET Core framework to enable full cross-platform support. There are no strings attached, no premium licenses or features, and no hidden agendas: just a team who want to build something better and work together to achieve it. We welcome anyone who is interested in joining us in our quest! -For further details, please see [our documentation page](https://docs.jellyfin.org/). To receive the latest updates, get help with Jellyfin, and join the community, please visit [one of our communication channels on Matrix/Riot or social media](https://docs.jellyfin.org/general/getting-help.html). +For further details, please see [our documentation page](https://docs.jellyfin.org/). To receive the latest updates, get help with Jellyfin, and join the community, please visit [one of our communication channels](https://docs.jellyfin.org/general/getting-help.html). For more information about the project, please see our [about page](https://docs.jellyfin.org/general/about.html). -For more information about the project, please see our [about page](https://docs.jellyfin.org/general/about.html). +Want to get started?
+Choose from Prebuilt Packages or Build from Source, then see our quick start guide.
-

-Want to get started? -Choose from Prebuilt Packages or Build from Source, then see our quick start guide. -

-

-Want to contribute? -Check out our documentation for guidelines. -

-

-New idea or improvement? -Check out our feature request hub. -

-

-Something not working right? -Open an Issue. -

+Something not working right?
+Open an Issue on GitHub.
+ +Want to contribute?
+Check out our documentation for guidelines.
+ +New idea or improvement?
+Check out our feature request hub.
+ +Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance linked above. Look through the following graphic to see if your native language could use some work! + + +Detailed Translation Status + From 27e3cf15588f8ab8fe19aa611d79fa2ccd8ecda8 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 15:27:58 +0100 Subject: [PATCH 12/44] Move appbuilder and service collection to Jellyfin.Server --- .../ApplicationHost.cs | 110 +++--------------- .../HttpServer/HttpListenerHost.cs | 3 +- .../Session/SessionWebSocketListener.cs | 4 +- Jellyfin.Api/Controllers/StartupController.cs | 2 +- .../StartupConfigurationDto.cs | 2 +- .../StartupUserDto.cs | 2 +- .../ApiApplicationBuilderExtensions.cs | 2 +- .../ApiServiceCollectionExtensions.cs | 11 +- Jellyfin.Server/Jellyfin.Server.csproj | 4 + Jellyfin.Server/Program.cs | 70 ++++++++++- Jellyfin.Server/Startup.cs | 81 +++++++++++++ .../IServerApplicationHost.cs | 5 + 12 files changed, 184 insertions(+), 112 deletions(-) rename Jellyfin.Api/Models/{Startup => StartupDtos}/StartupConfigurationDto.cs (93%) rename Jellyfin.Api/Models/{Startup => StartupDtos}/StartupUserDto.cs (89%) rename {Jellyfin.Api => Jellyfin.Server}/Extensions/ApiApplicationBuilderExtensions.cs (96%) rename {Jellyfin.Api => Jellyfin.Server}/Extensions/ApiServiceCollectionExtensions.cs (89%) create mode 100644 Jellyfin.Server/Startup.cs diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index c6cdd4786b..3b9ea41219 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -47,7 +47,6 @@ using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; using Emby.Server.Implementations.Updates; -using Jellyfin.Api.Extensions; using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; @@ -232,7 +231,7 @@ namespace Emby.Server.Implementations } } - protected IServiceProvider _serviceProvider; + public IServiceProvider ServiceProvider; /// /// Gets the server configuration manager. @@ -461,7 +460,7 @@ namespace Emby.Server.Implementations /// The type. /// System.Object. public object CreateInstance(Type type) - => ActivatorUtilities.CreateInstance(_serviceProvider, type); + => ActivatorUtilities.CreateInstance(ServiceProvider, type); /// /// Creates an instance of type and resolves all constructor dependencies @@ -469,7 +468,7 @@ namespace Emby.Server.Implementations /// /// The type. /// T. public T CreateInstance() - => ActivatorUtilities.CreateInstance(_serviceProvider); + => ActivatorUtilities.CreateInstance(ServiceProvider); /// /// Creates the instance safe. @@ -481,7 +480,7 @@ namespace Emby.Server.Implementations try { Logger.LogDebug("Creating instance of {Type}", type); - return ActivatorUtilities.CreateInstance(_serviceProvider, type); + return ActivatorUtilities.CreateInstance(ServiceProvider, type); } catch (Exception ex) { @@ -495,7 +494,7 @@ namespace Emby.Server.Implementations /// /// The type /// ``0. - public T Resolve() => _serviceProvider.GetService(); + public T Resolve() => ServiceProvider.GetService(); /// /// Gets the export types. @@ -611,93 +610,14 @@ namespace Emby.Server.Implementations await RegisterResources(serviceCollection).ConfigureAwait(false); - string contentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; - if (string.IsNullOrEmpty(contentRoot)) + ContentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath; + if (string.IsNullOrEmpty(ContentRoot)) { - contentRoot = ServerConfigurationManager.ApplicationPaths.WebPath; - } - - var host = new WebHostBuilder() - .UseKestrel(options => - { - var addresses = ServerConfigurationManager - .Configuration - .LocalNetworkAddresses - .Select(NormalizeConfiguredLocalAddress) - .Where(i => i != null) - .ToList(); - if (addresses.Any()) - { - foreach (var address in addresses) - { - Logger.LogInformation("Kestrel listening on {ipaddr}", address); - options.Listen(address, HttpPort); - - if (EnableHttps && Certificate != null) - { - options.Listen(address, HttpsPort, listenOptions => listenOptions.UseHttps(Certificate)); - } - } - } - else - { - Logger.LogInformation("Kestrel listening on all interfaces"); - options.ListenAnyIP(HttpPort); - - if (EnableHttps && Certificate != null) - { - options.ListenAnyIP(HttpsPort, listenOptions => listenOptions.UseHttps(Certificate)); - } - } - }) - .UseContentRoot(contentRoot) - .ConfigureServices(services => - { - services.AddResponseCompression(); - services.AddHttpContextAccessor(); - services.AddJellyfinApi(ServerConfigurationManager.Configuration.BaseUrl.TrimStart('/')); - - services.AddJellyfinApiSwagger(); - - // configure custom legacy authentication - services.AddCustomAuthentication(); - - services.AddJellyfinApiAuthorization(); - - // Merge the external ServiceCollection into ASP.NET DI - services.TryAdd(serviceCollection); - }) - .Configure(app => - { - app.UseWebSockets(); - - app.UseResponseCompression(); - - // TODO app.UseMiddleware(); - app.Use(ExecuteWebsocketHandlerAsync); - - // TODO use when old API is removed: app.UseAuthentication(); - app.UseJellyfinApiSwagger(); - app.UseMvc(); - app.Use(ExecuteHttpHandlerAsync); - }) - .Build(); - - _serviceProvider = host.Services; - FindParts(); - - try - { - await host.StartAsync().ConfigureAwait(false); - } - catch - { - Logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again."); - throw; + ContentRoot = ServerConfigurationManager.ApplicationPaths.WebPath; } } - private async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next) + public async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next) { if (!context.WebSockets.IsWebSocketRequest) { @@ -708,7 +628,7 @@ namespace Emby.Server.Implementations await HttpServer.ProcessWebSocketRequest(context).ConfigureAwait(false); } - private async Task ExecuteHttpHandlerAsync(HttpContext context, Func next) + public async Task ExecuteHttpHandlerAsync(HttpContext context, Func next) { if (context.WebSockets.IsWebSocketRequest) { @@ -1090,9 +1010,9 @@ namespace Emby.Server.Implementations /// /// Finds the parts. /// - protected void FindParts() + public void FindParts() { - InstallationManager = _serviceProvider.GetService(); + InstallationManager = ServiceProvider.GetService(); InstallationManager.PluginInstalled += PluginInstalled; if (!ServerConfigurationManager.Configuration.IsPortAuthorized) @@ -1221,7 +1141,7 @@ namespace Emby.Server.Implementations private CertificateInfo CertificateInfo { get; set; } - protected X509Certificate2 Certificate { get; private set; } + public X509Certificate2 Certificate { get; private set; } private IEnumerable GetUrlPrefixes() { @@ -1605,7 +1525,7 @@ namespace Emby.Server.Implementations return resultList; } - private IPAddress NormalizeConfiguredLocalAddress(string address) + public IPAddress NormalizeConfiguredLocalAddress(string address) { var index = address.Trim('/').IndexOf('/'); @@ -1685,6 +1605,8 @@ namespace Emby.Server.Implementations public int HttpsPort { get; private set; } + public string ContentRoot { get; private set; } + /// /// Shuts down. /// diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index dc1a56e271..6dd016f8a2 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -18,7 +18,6 @@ using MediaBrowser.Model.Events; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -164,7 +163,7 @@ namespace Emby.Server.Implementations.HttpServer { OnReceive = ProcessWebSocketMessageReceived, Url = e.Url, - QueryString = e.QueryString ?? new QueryCollection() + QueryString = e.QueryString }; connection.Closed += OnConnectionClosed; diff --git a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs index 63ec757626..930f2d35d3 100644 --- a/Emby.Server.Implementations/Session/SessionWebSocketListener.cs +++ b/Emby.Server.Implementations/Session/SessionWebSocketListener.cs @@ -4,7 +4,6 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; using MediaBrowser.Model.Events; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Services; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; @@ -67,7 +66,7 @@ namespace Emby.Server.Implementations.Session { if (queryString == null) { - throw new ArgumentNullException(nameof(queryString)); + return null; } var token = queryString["api_key"]; @@ -75,6 +74,7 @@ namespace Emby.Server.Implementations.Session { return null; } + var deviceId = queryString["deviceId"]; return _sessionManager.GetSessionByAuthenticationToken(token, deviceId, remoteEndpoint); } diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 0e7d17a27f..50f3dc83cf 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -1,6 +1,6 @@ using System.Linq; using System.Threading.Tasks; -using Jellyfin.Api.Models.Startup; +using Jellyfin.Api.Models.StartupDtos; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; using Microsoft.AspNetCore.Authorization; diff --git a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs similarity index 93% rename from Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs rename to Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs index dac15e412c..d048dad0a1 100644 --- a/Jellyfin.Api/Models/Startup/StartupConfigurationDto.cs +++ b/Jellyfin.Api/Models/StartupDtos/StartupConfigurationDto.cs @@ -1,4 +1,4 @@ -namespace Jellyfin.Api.Models.Startup +namespace Jellyfin.Api.Models.StartupDtos { /// /// The startup configuration DTO. diff --git a/Jellyfin.Api/Models/Startup/StartupUserDto.cs b/Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs similarity index 89% rename from Jellyfin.Api/Models/Startup/StartupUserDto.cs rename to Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs index 7e890d76a0..3a9348037a 100644 --- a/Jellyfin.Api/Models/Startup/StartupUserDto.cs +++ b/Jellyfin.Api/Models/StartupDtos/StartupUserDto.cs @@ -1,4 +1,4 @@ -namespace Jellyfin.Api.Models.Startup +namespace Jellyfin.Api.Models.StartupDtos { /// /// The startup user DTO. diff --git a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs similarity index 96% rename from Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs rename to Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs index f70466ebec..db06eb4552 100644 --- a/Jellyfin.Api/Extensions/ApiApplicationBuilderExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Builder; -namespace Jellyfin.Api.Extensions +namespace Jellyfin.Server.Extensions { /// /// Extensions for adding API specific functionality to the application pipeline. diff --git a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs similarity index 89% rename from Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs rename to Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index 38f5f6d390..e5a8937e87 100644 --- a/Jellyfin.Api/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -1,15 +1,14 @@ +using Jellyfin.Api; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; using Jellyfin.Api.Controllers; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; -namespace Jellyfin.Api.Extensions +namespace Jellyfin.Server.Extensions { /// /// API specific extensions for the service collection. @@ -65,14 +64,8 @@ namespace Jellyfin.Api.Extensions { return serviceCollection.AddMvc(opts => { - var policy = new AuthorizationPolicyBuilder() - .RequireAuthenticatedUser() - .Build(); - opts.Filters.Add(new AuthorizeFilter(policy)); - opts.EnableEndpointRouting = false; opts.UseGeneralRoutePrefix(baseUrl); }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) // Clear app parts to avoid other assemblies being picked up .ConfigureApplicationPartManager(a => a.ApplicationParts.Clear()) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index 4238d7fe3e..dc784becfb 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -20,6 +20,10 @@ + + + + diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e8bd0cd309..998f1125f5 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -18,8 +18,10 @@ using Jellyfin.Drawing.Skia; using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.Globalization; +using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Serilog; using Serilog.Extensions.Logging; @@ -164,7 +166,24 @@ namespace Jellyfin.Server appConfig); try { - await appHost.InitAsync(new ServiceCollection()).ConfigureAwait(false); + ServiceCollection serviceCollection = new ServiceCollection(); + await appHost.InitAsync(serviceCollection).ConfigureAwait(false); + + var host = CreateWebHostBuilder(appHost, serviceCollection).Build(); + + // A bit hacky to re-use service provider since ASP.NET doesn't allow a custom service collection. + appHost.ServiceProvider = host.Services; + appHost.FindParts(); + + try + { + await host.StartAsync().ConfigureAwait(false); + } + catch + { + _logger.LogError("Kestrel failed to start! This is most likely due to an invalid address or port bind - correct your bind configuration in system.xml and try again."); + throw; + } appHost.ImageProcessor.ImageEncoder = GetImageEncoder(appPaths, appHost.LocalizationManager); @@ -196,6 +215,55 @@ namespace Jellyfin.Server } } + private static IWebHostBuilder CreateWebHostBuilder(ApplicationHost appHost, IServiceCollection serviceCollection) + { + return new WebHostBuilder() + .UseKestrel(options => + { + var addresses = appHost.ServerConfigurationManager + .Configuration + .LocalNetworkAddresses + .Select(appHost.NormalizeConfiguredLocalAddress) + .Where(i => i != null) + .ToList(); + if (addresses.Any()) + { + foreach (var address in addresses) + { + _logger.LogInformation("Kestrel listening on {ipaddr}", address); + options.Listen(address, appHost.HttpPort); + + if (appHost.EnableHttps && appHost.Certificate != null) + { + options.Listen( + address, + appHost.HttpsPort, + listenOptions => listenOptions.UseHttps(appHost.Certificate)); + } + } + } + else + { + _logger.LogInformation("Kestrel listening on all interfaces"); + options.ListenAnyIP(appHost.HttpPort); + + if (appHost.EnableHttps && appHost.Certificate != null) + { + options.ListenAnyIP( + appHost.HttpsPort, + listenOptions => listenOptions.UseHttps(appHost.Certificate)); + } + } + }) + .UseContentRoot(appHost.ContentRoot) + .ConfigureServices(services => + { + // Merge the external ServiceCollection into ASP.NET DI + services.TryAdd(serviceCollection); + }) + .UseStartup(); + } + /// /// Create the data, config and log paths from the variety of inputs(command line args, /// environment variables) or decide on what default to use. For Windows it's %AppPath% diff --git a/Jellyfin.Server/Startup.cs b/Jellyfin.Server/Startup.cs new file mode 100644 index 0000000000..3ee5fb8b50 --- /dev/null +++ b/Jellyfin.Server/Startup.cs @@ -0,0 +1,81 @@ +using Jellyfin.Server.Extensions; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Configuration; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Jellyfin.Server +{ + /// + /// Startup configuration for the Kestrel webhost. + /// + public class Startup + { + private readonly IServerConfigurationManager _serverConfigurationManager; + + /// + /// Initializes a new instance of the class. + /// + /// The server configuration manager. + public Startup(IServerConfigurationManager serverConfigurationManager) + { + _serverConfigurationManager = serverConfigurationManager; + } + + /// + /// Configures the service collection for the webhost. + /// + /// The service collection. + public void ConfigureServices(IServiceCollection services) + { + services.AddResponseCompression(); + services.AddHttpContextAccessor(); + services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/')); + + services.AddJellyfinApiSwagger(); + + // configure custom legacy authentication + services.AddCustomAuthentication(); + + services.AddJellyfinApiAuthorization(); + } + + /// + /// Configures the app builder for the webhost. + /// + /// The application builder. + /// The webhost environment. + /// The server application host. + public void Configure( + IApplicationBuilder app, + IWebHostEnvironment env, + IServerApplicationHost serverApplicationHost) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseWebSockets(); + + app.UseResponseCompression(); + + // TODO app.UseMiddleware(); + app.Use(serverApplicationHost.ExecuteWebsocketHandlerAsync); + + // TODO use when old API is removed: app.UseAuthentication(); + app.UseJellyfinApiSwagger(); + app.UseRouting(); + app.UseAuthorization(); + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + app.Use(serverApplicationHost.ExecuteHttpHandlerAsync); + } + } +} diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 61b2c15ae2..b3c56bdd5f 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Common; using MediaBrowser.Model.System; +using Microsoft.AspNetCore.Http; namespace MediaBrowser.Controller { @@ -87,5 +88,9 @@ namespace MediaBrowser.Controller string ExpandVirtualPath(string path); string ReverseVirtualPath(string path); + + Task ExecuteHttpHandlerAsync(HttpContext context, Func next); + + Task ExecuteWebsocketHandlerAsync(HttpContext context, Func next); } } From 6a6bfa6da9ac4b2c54d0eba88e3d30c4147a2379 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Sun, 24 Nov 2019 17:08:28 +0100 Subject: [PATCH 13/44] Fix possible nullref when updating packages --- .../Emby.Server.Implementations.csproj | 1 + .../ScheduledTasks/Tasks/PluginUpdateTask.cs | 4 +++- .../Updates/InstallationManager.cs | 18 +++++++++++------- .../Updates/IInstallationManager.cs | 2 +- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index 214ea5aff9..385664737d 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -36,6 +36,7 @@ + diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs index fe8deae595..909fffb1ff 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/PluginUpdateTask.cs @@ -52,7 +52,9 @@ namespace Emby.Server.Implementations.ScheduledTasks { progress.Report(0); - var packagesToInstall = (await _installationManager.GetAvailablePluginUpdates(cancellationToken).ConfigureAwait(false)).ToList(); + var packagesToInstall = await _installationManager.GetAvailablePluginUpdates(cancellationToken) + .ToListAsync(cancellationToken) + .ConfigureAwait(false); progress.Report(10); diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs index 1c54022682..09a5a0dca8 100644 --- a/Emby.Server.Implementations/Updates/InstallationManager.cs +++ b/Emby.Server.Implementations/Updates/InstallationManager.cs @@ -180,7 +180,7 @@ namespace Emby.Server.Implementations.Updates // Package not found. if (package == null) { - return null; + return Enumerable.Empty(); } return GetCompatibleVersions( @@ -190,19 +190,23 @@ namespace Emby.Server.Implementations.Updates } /// - public async Task> GetAvailablePluginUpdates(CancellationToken cancellationToken = default) + public async IAsyncEnumerable GetAvailablePluginUpdates(CancellationToken cancellationToken = default) { var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false); var systemUpdateLevel = _applicationHost.SystemUpdateLevel; // Figure out what needs to be installed - return _applicationHost.Plugins.Select(x => + foreach (var plugin in _applicationHost.Plugins) { - var compatibleversions = GetCompatibleVersions(catalog, x.Name, x.Id, x.Version, systemUpdateLevel); - return compatibleversions.FirstOrDefault(y => y.Version > x.Version); - }).Where(x => x != null) - .Where(x => !CompletedInstallations.Any(y => string.Equals(y.AssemblyGuid, x.guid, StringComparison.OrdinalIgnoreCase))); + var compatibleversions = GetCompatibleVersions(catalog, plugin.Name, plugin.Id, plugin.Version, systemUpdateLevel); + var version = compatibleversions.FirstOrDefault(y => y.Version > plugin.Version); + if (version != null + && !CompletedInstallations.Any(x => string.Equals(x.AssemblyGuid, version.guid, StringComparison.OrdinalIgnoreCase))) + { + yield return version; + } + } } /// diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs index 524d8f3c69..e49812f150 100644 --- a/MediaBrowser.Common/Updates/IInstallationManager.cs +++ b/MediaBrowser.Common/Updates/IInstallationManager.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Common.Updates /// /// The cancellation token. /// The available plugin updates. - Task> GetAvailablePluginUpdates(CancellationToken cancellationToken = default); + IAsyncEnumerable GetAvailablePluginUpdates(CancellationToken cancellationToken = default); /// /// Installs the package. From 2af5922af06c865d676e817112ef76a92a23e1b6 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 18:25:43 +0100 Subject: [PATCH 14/44] Fix review comments --- Emby.Server.Implementations/ApplicationHost.cs | 7 +++++-- .../HttpServer/Security/AuthService.cs | 4 ++-- Jellyfin.Api/Auth/CustomAuthenticationHandler.cs | 4 ++-- .../FirstTimeSetupOrElevatedHandler.cs | 4 ++-- .../RequiresElevationHandler.cs | 4 ++-- Jellyfin.Api/{Enums => Constants}/UserRole.cs | 12 ++++++------ Jellyfin.Api/Jellyfin.Api.csproj | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) rename Jellyfin.Api/{Enums => Constants}/UserRole.cs (51%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3b9ea41219..4fd08258af 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -231,7 +231,10 @@ namespace Emby.Server.Implementations } } - public IServiceProvider ServiceProvider; + /// + /// Gets or sets the service provider. + /// + public IServiceProvider ServiceProvider { get; set; } /// /// Gets the server configuration manager. @@ -835,7 +838,7 @@ namespace Emby.Server.Implementations serviceCollection.AddSingleton(authContext); serviceCollection.AddSingleton(new SessionContext(UserManager, authContext, SessionManager)); - AuthService = new AuthService(LoggerFactory, authContext, ServerConfigurationManager, SessionManager, NetworkManager); + AuthService = new AuthService(LoggerFactory.CreateLogger(), authContext, ServerConfigurationManager, SessionManager, NetworkManager); serviceCollection.AddSingleton(AuthService); SubtitleEncoder = new MediaBrowser.MediaEncoding.Subtitles.SubtitleEncoder(LibraryManager, LoggerFactory, ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer, HttpClient, MediaSourceManager, ProcessFactory); diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs index 81dab83d5e..594f464989 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthService.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthService.cs @@ -22,13 +22,13 @@ namespace Emby.Server.Implementations.HttpServer.Security private readonly INetworkManager _networkManager; public AuthService( - ILoggerFactory loggerFactory, + ILogger logger, IAuthorizationContext authorizationContext, IServerConfigurationManager config, ISessionManager sessionManager, INetworkManager networkManager) { - _logger = loggerFactory.CreateLogger(); + _logger = logger; _authorizationContext = authorizationContext; _config = config; _sessionManager = sessionManager; diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index a753d60838..6ca992c61b 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -1,7 +1,7 @@ using System.Security.Claims; using System.Text.Encodings.Web; using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using MediaBrowser.Controller.Net; using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.Logging; @@ -51,7 +51,7 @@ namespace Jellyfin.Api.Auth new Claim(ClaimTypes.Name, user.Name), new Claim( ClaimTypes.Role, - value: user.Policy.IsAdministrator ? UserRole.Administrator.ToString() : UserRole.User.ToString()) + value: user.Policy.IsAdministrator ? UserRole.Administrator : UserRole.User) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index f07e568dea..2450e7bc73 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using MediaBrowser.Common.Configuration; using Microsoft.AspNetCore.Authorization; @@ -28,7 +28,7 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole(UserRole.Administrator.ToString())) + else if (context.User.IsInRole(UserRole.Administrator)) { context.Succeed(firstTimeSetupOrElevatedRequirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 8674f3e262..108c29a2cc 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Jellyfin.Api.Enums; +using Jellyfin.Api.Constants; using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.RequiresElevationPolicy @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Auth.RequiresElevationPolicy /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole(UserRole.Administrator.ToString())) + if (context.User.IsInRole(UserRole.Administrator)) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Enums/UserRole.cs b/Jellyfin.Api/Constants/UserRole.cs similarity index 51% rename from Jellyfin.Api/Enums/UserRole.cs rename to Jellyfin.Api/Constants/UserRole.cs index 05826d9f41..b1da615575 100644 --- a/Jellyfin.Api/Enums/UserRole.cs +++ b/Jellyfin.Api/Constants/UserRole.cs @@ -1,23 +1,23 @@ -namespace Jellyfin.Api.Enums +namespace Jellyfin.Api.Constants { /// - /// Enum for user roles used in the authentication and authorization for the API. + /// Constants for user roles used in the authentication and authorization for the API. /// - public enum UserRole + public static class UserRole { /// /// Guest user. /// - Guest = 0, + public const string Guest = "Guest"; /// /// Regular user with no special privileges. /// - User = 1, + public const string User = "User"; /// /// Administrator user with elevated privileges. /// - Administrator = 2 + public const string Administrator = "Administrator"; } } diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 1cc23c07b4..6ad97b60f3 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -19,7 +19,7 @@ - + From 47a4f2f387825d9c249c53b3796a43e3eac52b58 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Sun, 24 Nov 2019 19:25:46 +0100 Subject: [PATCH 15/44] Fix more review comments --- .../ApplicationHost.cs | 21 +++++++++++++------ .../Auth/CustomAuthenticationHandler.cs | 2 +- .../FirstTimeSetupOrElevatedHandler.cs | 2 +- .../RequiresElevationHandler.cs | 2 +- .../Constants/AuthenticationSchemes.cs | 13 ++++++++++++ Jellyfin.Api/Constants/Policies.cs | 18 ++++++++++++++++ .../Constants/{UserRole.cs => UserRoles.cs} | 2 +- Jellyfin.Api/Controllers/StartupController.cs | 3 ++- Jellyfin.Api/Jellyfin.Api.csproj | 6 +++--- .../ApiServiceCollectionExtensions.cs | 13 ++++++------ 10 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 Jellyfin.Api/Constants/AuthenticationSchemes.cs create mode 100644 Jellyfin.Api/Constants/Policies.cs rename Jellyfin.Api/Constants/{UserRole.cs => UserRoles.cs} (94%) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 4fd08258af..c5f8b58c44 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -236,6 +236,21 @@ namespace Emby.Server.Implementations /// public IServiceProvider ServiceProvider { get; set; } + /// + /// Gets the http port for the webhost. + /// + public int HttpPort { get; private set; } + + /// + /// Gets the https port for the webhost. + /// + public int HttpsPort { get; private set; } + + /// + /// Gets the content root for the webhost. + /// + public string ContentRoot { get; private set; } + /// /// Gets the server configuration manager. /// @@ -1604,12 +1619,6 @@ namespace Emby.Server.Implementations ? Environment.MachineName : ServerConfigurationManager.Configuration.ServerName; - public int HttpPort { get; private set; } - - public int HttpsPort { get; private set; } - - public string ContentRoot { get; private set; } - /// /// Shuts down. /// diff --git a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs index 6ca992c61b..26f7d9d2dd 100644 --- a/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs +++ b/Jellyfin.Api/Auth/CustomAuthenticationHandler.cs @@ -51,7 +51,7 @@ namespace Jellyfin.Api.Auth new Claim(ClaimTypes.Name, user.Name), new Claim( ClaimTypes.Role, - value: user.Policy.IsAdministrator ? UserRole.Administrator : UserRole.User) + value: user.Policy.IsAdministrator ? UserRoles.Administrator : UserRoles.User) }; var identity = new ClaimsIdentity(claims, Scheme.Name); var principal = new ClaimsPrincipal(identity); diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs index 2450e7bc73..34aa5d12c8 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedHandler.cs @@ -28,7 +28,7 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { context.Succeed(firstTimeSetupOrElevatedRequirement); } - else if (context.User.IsInRole(UserRole.Administrator)) + else if (context.User.IsInRole(UserRoles.Administrator)) { context.Succeed(firstTimeSetupOrElevatedRequirement); } diff --git a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs index 108c29a2cc..2d3bb1aa48 100644 --- a/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs +++ b/Jellyfin.Api/Auth/RequiresElevationPolicy/RequiresElevationHandler.cs @@ -12,7 +12,7 @@ namespace Jellyfin.Api.Auth.RequiresElevationPolicy /// protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RequiresElevationRequirement requirement) { - if (context.User.IsInRole(UserRole.Administrator)) + if (context.User.IsInRole(UserRoles.Administrator)) { context.Succeed(requirement); } diff --git a/Jellyfin.Api/Constants/AuthenticationSchemes.cs b/Jellyfin.Api/Constants/AuthenticationSchemes.cs new file mode 100644 index 0000000000..bac3379e71 --- /dev/null +++ b/Jellyfin.Api/Constants/AuthenticationSchemes.cs @@ -0,0 +1,13 @@ +namespace Jellyfin.Api.Constants +{ + /// + /// Authentication schemes for user authentication in the API. + /// + public static class AuthenticationSchemes + { + /// + /// Scheme name for the custom legacy authentication. + /// + public const string CustomAuthentication = "CustomAuthentication"; + } +} diff --git a/Jellyfin.Api/Constants/Policies.cs b/Jellyfin.Api/Constants/Policies.cs new file mode 100644 index 0000000000..e2b383f75d --- /dev/null +++ b/Jellyfin.Api/Constants/Policies.cs @@ -0,0 +1,18 @@ +namespace Jellyfin.Api.Constants +{ + /// + /// Policies for the API authorization. + /// + public static class Policies + { + /// + /// Policy name for requiring first time setup or elevated privileges. + /// + public const string FirstTimeSetupOrElevated = "FirstTimeOrElevated"; + + /// + /// Policy name for requiring elevated privileges. + /// + public const string RequiresElevation = "RequiresElevation"; + } +} diff --git a/Jellyfin.Api/Constants/UserRole.cs b/Jellyfin.Api/Constants/UserRoles.cs similarity index 94% rename from Jellyfin.Api/Constants/UserRole.cs rename to Jellyfin.Api/Constants/UserRoles.cs index b1da615575..d9a536e7d7 100644 --- a/Jellyfin.Api/Constants/UserRole.cs +++ b/Jellyfin.Api/Constants/UserRoles.cs @@ -3,7 +3,7 @@ namespace Jellyfin.Api.Constants /// /// Constants for user roles used in the authentication and authorization for the API. /// - public static class UserRole + public static class UserRoles { /// /// Guest user. diff --git a/Jellyfin.Api/Controllers/StartupController.cs b/Jellyfin.Api/Controllers/StartupController.cs index 50f3dc83cf..1014c8c56b 100644 --- a/Jellyfin.Api/Controllers/StartupController.cs +++ b/Jellyfin.Api/Controllers/StartupController.cs @@ -1,5 +1,6 @@ using System.Linq; using System.Threading.Tasks; +using Jellyfin.Api.Constants; using Jellyfin.Api.Models.StartupDtos; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Library; @@ -11,7 +12,7 @@ namespace Jellyfin.Api.Controllers /// /// The startup wizard controller. /// - [Authorize(Policy = "FirstTimeSetupOrElevated")] + [Authorize(Policy = Policies.FirstTimeSetupOrElevated)] public class StartupController : BaseJellyfinApiController { private readonly IServerConfigurationManager _config; diff --git a/Jellyfin.Api/Jellyfin.Api.csproj b/Jellyfin.Api/Jellyfin.Api.csproj index 6ad97b60f3..a2818b45da 100644 --- a/Jellyfin.Api/Jellyfin.Api.csproj +++ b/Jellyfin.Api/Jellyfin.Api.csproj @@ -20,9 +20,9 @@ - - - + + + diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs index e5a8937e87..dd4f9cd238 100644 --- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs +++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs @@ -2,6 +2,7 @@ using Jellyfin.Api; using Jellyfin.Api.Auth; using Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy; using Jellyfin.Api.Auth.RequiresElevationPolicy; +using Jellyfin.Api.Constants; using Jellyfin.Api.Controllers; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; @@ -27,17 +28,17 @@ namespace Jellyfin.Server.Extensions return serviceCollection.AddAuthorizationCore(options => { options.AddPolicy( - "RequiresElevation", + Policies.RequiresElevation, policy => { - policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication); policy.AddRequirements(new RequiresElevationRequirement()); }); options.AddPolicy( - "FirstTimeSetupOrElevated", + Policies.FirstTimeSetupOrElevated, policy => { - policy.AddAuthenticationSchemes("CustomAuthentication"); + policy.AddAuthenticationSchemes(AuthenticationSchemes.CustomAuthentication); policy.AddRequirements(new FirstTimeSetupOrElevatedRequirement()); }); }); @@ -50,8 +51,8 @@ namespace Jellyfin.Server.Extensions /// The updated service collection. public static AuthenticationBuilder AddCustomAuthentication(this IServiceCollection serviceCollection) { - return serviceCollection.AddAuthentication("CustomAuthentication") - .AddScheme("CustomAuthentication", null); + return serviceCollection.AddAuthentication(AuthenticationSchemes.CustomAuthentication) + .AddScheme(AuthenticationSchemes.CustomAuthentication, null); } /// From f12c9bf3b0d1ad4c6bdcafc1ac97cee191a517fc Mon Sep 17 00:00:00 2001 From: Erwin de Haan Date: Sun, 24 Nov 2019 23:01:18 +0100 Subject: [PATCH 16/44] Added tag building support to Windows Web build. --- .ci/azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/azure-pipelines.yml b/.ci/azure-pipelines.yml index c829da98af..13cc67528f 100644 --- a/.ci/azure-pipelines.yml +++ b/.ci/azure-pipelines.yml @@ -200,8 +200,8 @@ jobs: persistCredentials: true - task: CmdLine@2 - displayName: "Check out web" - condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion')) + displayName: "Check out web (master, release or tag)" + condition: and(succeeded(), or(contains(variables['Build.SourceBranch'], 'release'), contains(variables['Build.SourceBranch'], 'master'), contains(variables['Build.SourceBranch'], 'tag')) ,eq(variables['BuildConfiguration'], 'Release'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI', 'BuildCompletion')) inputs: script: 'git clone --single-branch --branch $(Build.SourceBranchName) --depth=1 https://github.com/jellyfin/jellyfin-web.git $(Agent.TempDirectory)/jellyfin-web' From 69d76af054dd41cb729edc6d866413aa7e2de622 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Mon, 25 Nov 2019 10:56:23 +0100 Subject: [PATCH 17/44] dlna GetPathValue Forgot to update this last time, just copied the code from `MediaBrowser.Api/BaseApiService.cs` --- Emby.Dlna/Api/DlnaServerService.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Emby.Dlna/Api/DlnaServerService.cs b/Emby.Dlna/Api/DlnaServerService.cs index 1f137e620c..7ddcaf7e6e 100644 --- a/Emby.Dlna/Api/DlnaServerService.cs +++ b/Emby.Dlna/Api/DlnaServerService.cs @@ -214,11 +214,13 @@ namespace Emby.Dlna.Api string baseUrl = _configurationManager.Configuration.BaseUrl; // backwards compatibility - if (baseUrl.Length == 0 - && (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) - || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase))) + if (baseUrl.Length == 0) { - index++; + if (string.Equals(first, "mediabrowser", StringComparison.OrdinalIgnoreCase) + || string.Equals(first, "emby", StringComparison.OrdinalIgnoreCase)) + { + index++; + } } else if (string.Equals(first, baseUrl.Remove(0, 1))) { @@ -234,7 +236,7 @@ namespace Emby.Dlna.Api return pathInfo[index]; } - private List Parse(string pathUri) + private static string[] Parse(string pathUri) { var actionParts = pathUri.Split(new[] { "://" }, StringSplitOptions.None); @@ -248,7 +250,7 @@ namespace Emby.Dlna.Api var args = pathInfo.Split('/'); - return args.Skip(1).ToList(); + return args.Skip(1).ToArray(); } public object Get(GetIcon request) From a4c2886ac0c8eced40cf0e49c128e5b17208e9fb Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Mon, 25 Nov 2019 11:04:51 +0100 Subject: [PATCH 18/44] Fix master build I was wrong, it did break... --- .../ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs index 91d990137d..72b524df02 100644 --- a/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs +++ b/Emby.Server.Implementations/ScheduledTasks/Tasks/DeleteTranscodeFileTask.cs @@ -47,7 +47,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks var minDateModified = DateTime.UtcNow.AddDays(-1); progress.Report(50); - DeleteTempFilesFromDirectory(cancellationToken, _configurationManager.GetTranscodingTempPath(), minDateModified, progress); + DeleteTempFilesFromDirectory(cancellationToken, _configurationManager.GetTranscodePath(), minDateModified, progress); return Task.CompletedTask; } From 65ae4eb0dd4f08a621f4d30c18af930785a60841 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 26 Nov 2019 00:32:14 +0900 Subject: [PATCH 19/44] fix some html tags in the readme --- README.md | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 268b28db7f..bbac4dd25a 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,39 @@

Logo Banner -

-GPL 2.0 License -Current Release -Translation Status -Azure Builds -Docker Pull Count +
+
+ +GPL 2.0 License + + +Current Release + + +Translation Status + + +Azure Builds + + +Docker Pull Count +
-Donate -Submit Feature Requests -Discuss on our Forum -Chat on Matrix -Join our Subreddit + +Donate + + +Submit Feature Requests + + +Discuss on our Forum + + +Chat on Matrix + + +Join our Subreddit +

--- @@ -37,7 +58,7 @@ Check out ou New idea or improvement?
Check out our
feature request hub.
-Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance linked above. Look through the following graphic to see if your native language could use some work! +Most of the translations can be found in the web client but we have several other clients that have missing strings. Translations can be improved very easily from our Weblate instance. Look through the following graphic to see if your native language could use some work! Detailed Translation Status From 94ef239de0087ed4df490673b5b395d8b0111e8f Mon Sep 17 00:00:00 2001 From: ferferga Date: Mon, 25 Nov 2019 23:09:23 +0100 Subject: [PATCH 20/44] Add full Raspberry Pi hardware decoding support --- .../MediaEncoding/EncodingHelper.cs | 16 ++++++++++++++-- .../Encoder/EncoderValidator.cs | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 349e371a7b..0664bdd984 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -2529,13 +2529,25 @@ namespace MediaBrowser.Controller.MediaEncoding case "h264": if (_mediaEncoder.SupportsDecoder("h264_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) { - return "-c:v h264_mmal"; + return "-c:v h264_mmal "; } break; case "mpeg2video": if (_mediaEncoder.SupportsDecoder("mpeg2_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase)) { - return "-c:v mpeg2_mmal"; + return "-c:v mpeg2_mmal "; + } + break; + case "mpeg4": + if (_mediaEncoder.SupportsDecoder("mpeg4_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v mpeg4_mmal "; + } + break; + case "vc1": + if (_mediaEncoder.SupportsDecoder("vc1_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v vc1_mmal "; } break; } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs index 3620abfee7..1feca0ec92 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncoderValidator.cs @@ -18,7 +18,10 @@ namespace MediaBrowser.MediaEncoding.Encoder "h264_qsv", "hevc_qsv", "mpeg2_qsv", + "mpeg2_mmal", + "mpeg4_mmal", "vc1_qsv", + "vc1_mmal", "h264_cuvid", "hevc_cuvid", "dts", @@ -26,6 +29,7 @@ namespace MediaBrowser.MediaEncoding.Encoder "aac", "mp3", "h264", + "h264_mmal", "hevc" }; From 50a535e6e4f53e8aa003e7c5343e8341a06686dc Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 26 Nov 2019 09:47:26 +0100 Subject: [PATCH 21/44] Use .Net Core 3.0 in all docker images --- deployment/debian-package-arm64/Dockerfile.amd64 | 6 +++--- deployment/debian-package-arm64/Dockerfile.arm64 | 4 ++-- deployment/debian-package-arm64/docker-build.sh | 4 ++-- deployment/debian-package-armhf/Dockerfile.amd64 | 6 +++--- deployment/debian-package-armhf/Dockerfile.armhf | 4 ++-- deployment/debian-package-armhf/docker-build.sh | 4 ++-- deployment/debian-package-x64/Dockerfile | 4 ++-- deployment/debian-package-x64/docker-build.sh | 4 ++-- deployment/debian-package-x64/pkg-src/control | 2 +- deployment/linux-x64/Dockerfile | 4 ++-- deployment/macos/Dockerfile | 4 ++-- deployment/portable/Dockerfile | 4 ++-- deployment/ubuntu-package-arm64/Dockerfile.amd64 | 6 +++--- deployment/ubuntu-package-arm64/Dockerfile.arm64 | 4 ++-- deployment/ubuntu-package-arm64/docker-build.sh | 4 ++-- deployment/ubuntu-package-armhf/Dockerfile.amd64 | 6 +++--- deployment/ubuntu-package-armhf/Dockerfile.armhf | 4 ++-- deployment/ubuntu-package-armhf/docker-build.sh | 4 ++-- deployment/ubuntu-package-x64/docker-build.sh | 4 ++-- deployment/win-x64/Dockerfile | 4 ++-- deployment/win-x86/Dockerfile | 4 ++-- 21 files changed, 45 insertions(+), 45 deletions(-) diff --git a/deployment/debian-package-arm64/Dockerfile.amd64 b/deployment/debian-package-arm64/Dockerfile.amd64 index 7a674d029b..069c2ed352 100644 --- a/deployment/debian-package-arm64/Dockerfile.amd64 +++ b/deployment/debian-package-arm64/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/debian-package-arm64/Dockerfile.arm64 b/deployment/debian-package-arm64/Dockerfile.arm64 index 2b43d70aca..d2e1c1f121 100644 --- a/deployment/debian-package-arm64/Dockerfile.arm64 +++ b/deployment/debian-package-arm64/Dockerfile.arm64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/1560f31a-d566-4de0-9fef-1a40b2b2a748/163f23fb8018e064034f3492f54358f1/dotnet-sdk-2.2.401-linux-arm64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/89fb60b1-3359-414e-94cf-359f57f37c7c/256e6dac8f44f9bad01f23f9a27b01ee/dotnet-sdk-3.0.101-linux-arm64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/debian-package-arm64/docker-build.sh b/deployment/debian-package-arm64/docker-build.sh index 1c75ece8eb..b36b928ba1 100755 --- a/deployment/debian-package-arm64/docker-build.sh +++ b/deployment/debian-package-arm64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/debian-package-armhf/Dockerfile.amd64 b/deployment/debian-package-armhf/Dockerfile.amd64 index 2f15d2fcdf..d0afbed51c 100644 --- a/deployment/debian-package-armhf/Dockerfile.amd64 +++ b/deployment/debian-package-armhf/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget npm devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/debian-package-armhf/Dockerfile.armhf b/deployment/debian-package-armhf/Dockerfile.armhf index 17a6fa0a1d..dd9e3297e8 100644 --- a/deployment/debian-package-armhf/Dockerfile.armhf +++ b/deployment/debian-package-armhf/Dockerfile.armhf @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/3cb1d917-19cc-4399-9a53-03bb5de223f6/be3e011601610d9fe0a4f6b1962378ea/dotnet-sdk-2.2.401-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/0b30374c-3d52-45ad-b4e5-9a39d0bf5bf0/deb17f7b32968b3a2186650711456152/dotnet-sdk-3.0.101-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/debian-package-armhf/docker-build.sh b/deployment/debian-package-armhf/docker-build.sh index df35345bdd..1b3af9a937 100755 --- a/deployment/debian-package-armhf/docker-build.sh +++ b/deployment/debian-package-armhf/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/debian-package-x64/Dockerfile b/deployment/debian-package-x64/Dockerfile index 172bbe8fc5..36e8cf3224 100644 --- a/deployment/debian-package-x64/Dockerfile +++ b/deployment/debian-package-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/debian-package-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/debian-package-x64/docker-build.sh b/deployment/debian-package-x64/docker-build.sh index 9781879f6f..bb27bc7ee8 100755 --- a/deployment/debian-package-x64/docker-build.sh +++ b/deployment/debian-package-x64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB dpkg-buildpackage -us -uc diff --git a/deployment/debian-package-x64/pkg-src/control b/deployment/debian-package-x64/pkg-src/control index e8c9d2e23b..07e82069fc 100644 --- a/deployment/debian-package-x64/pkg-src/control +++ b/deployment/debian-package-x64/pkg-src/control @@ -3,7 +3,7 @@ Section: misc Priority: optional Maintainer: Jellyfin Team Build-Depends: debhelper (>= 9), - dotnet-sdk-2.2, + dotnet-sdk-3.0, libc6-dev, libcurl4-openssl-dev, libfontconfig1-dev, diff --git a/deployment/linux-x64/Dockerfile b/deployment/linux-x64/Dockerfile index d634b55de9..169d07a574 100644 --- a/deployment/linux-x64/Dockerfile +++ b/deployment/linux-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/linux-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/macos/Dockerfile b/deployment/macos/Dockerfile index 406a2d853e..c8b4e80bfc 100644 --- a/deployment/macos/Dockerfile +++ b/deployment/macos/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/macos ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/portable/Dockerfile b/deployment/portable/Dockerfile index bdbf978fe7..17297a298f 100644 --- a/deployment/portable/Dockerfile +++ b/deployment/portable/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/portable ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/ubuntu-package-arm64/Dockerfile.amd64 b/deployment/ubuntu-package-arm64/Dockerfile.amd64 index 44e67a4062..fac00ffeab 100644 --- a/deployment/ubuntu-package-arm64/Dockerfile.amd64 +++ b/deployment/ubuntu-package-arm64/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/69937b49-a877-4ced-81e6-286620b390ab/8ab938cf6f5e83b2221630354160ef21/dotnet-sdk-2.2.104-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/ubuntu-package-arm64/Dockerfile.arm64 b/deployment/ubuntu-package-arm64/Dockerfile.arm64 index 58f3d3aaff..304cd0efd0 100644 --- a/deployment/ubuntu-package-arm64/Dockerfile.arm64 +++ b/deployment/ubuntu-package-arm64/Dockerfile.arm64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-arm64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/d9f37b73-df8d-4dfa-a905-b7648d3401d0/6312573ac13d7a8ddc16e4058f7d7dc5/dotnet-sdk-2.2.104-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/89fb60b1-3359-414e-94cf-359f57f37c7c/256e6dac8f44f9bad01f23f9a27b01ee/dotnet-sdk-3.0.101-linux-arm64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/ubuntu-package-arm64/docker-build.sh b/deployment/ubuntu-package-arm64/docker-build.sh index 1c75ece8eb..b36b928ba1 100755 --- a/deployment/ubuntu-package-arm64/docker-build.sh +++ b/deployment/ubuntu-package-arm64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/ubuntu-package-armhf/Dockerfile.amd64 b/deployment/ubuntu-package-armhf/Dockerfile.amd64 index d69a75b503..3c60537759 100644 --- a/deployment/ubuntu-package-armhf/Dockerfile.amd64 +++ b/deployment/ubuntu-package-armhf/Dockerfile.amd64 @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -12,11 +12,11 @@ ENV ARCH=amd64 # Prepare Debian build environment RUN apt-get update \ - && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv + && apt-get install -y apt-transport-https debhelper gnupg wget devscripts mmv # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/69937b49-a877-4ced-81e6-286620b390ab/8ab938cf6f5e83b2221630354160ef21/dotnet-sdk-2.2.104-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/ubuntu-package-armhf/Dockerfile.armhf b/deployment/ubuntu-package-armhf/Dockerfile.armhf index 5d1025080a..1d019bf2df 100644 --- a/deployment/ubuntu-package-armhf/Dockerfile.armhf +++ b/deployment/ubuntu-package-armhf/Dockerfile.armhf @@ -3,7 +3,7 @@ FROM ubuntu:bionic ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/ubuntu-package-armhf ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/d9f37b73-df8d-4dfa-a905-b7648d3401d0/6312573ac13d7a8ddc16e4058f7d7dc5/dotnet-sdk-2.2.104-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/0b30374c-3d52-45ad-b4e5-9a39d0bf5bf0/deb17f7b32968b3a2186650711456152/dotnet-sdk-3.0.101-linux-arm.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/ubuntu-package-armhf/docker-build.sh b/deployment/ubuntu-package-armhf/docker-build.sh index df35345bdd..1b3af9a937 100755 --- a/deployment/ubuntu-package-armhf/docker-build.sh +++ b/deployment/ubuntu-package-armhf/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB export CONFIG_SITE=/etc/dpkg-cross/cross-config.${ARCH} diff --git a/deployment/ubuntu-package-x64/docker-build.sh b/deployment/ubuntu-package-x64/docker-build.sh index 9781879f6f..bb27bc7ee8 100755 --- a/deployment/ubuntu-package-x64/docker-build.sh +++ b/deployment/ubuntu-package-x64/docker-build.sh @@ -8,8 +8,8 @@ set -o xtrace # Move to source directory pushd ${SOURCE_DIR} -# Remove build-dep for dotnet-sdk-2.2, since it's not a package in this image -sed -i '/dotnet-sdk-2.2,/d' debian/control +# Remove build-dep for dotnet-sdk-3.0, since it's not a package in this image +sed -i '/dotnet-sdk-3.0,/d' debian/control # Build DEB dpkg-buildpackage -us -uc diff --git a/deployment/win-x64/Dockerfile b/deployment/win-x64/Dockerfile index 7f64c7daed..0f85a07d86 100644 --- a/deployment/win-x64/Dockerfile +++ b/deployment/win-x64/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/win-x64 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet diff --git a/deployment/win-x86/Dockerfile b/deployment/win-x86/Dockerfile index fb5f5d6b61..f07a8d7fe3 100644 --- a/deployment/win-x86/Dockerfile +++ b/deployment/win-x86/Dockerfile @@ -3,7 +3,7 @@ FROM debian:10 ARG SOURCE_DIR=/jellyfin ARG PLATFORM_DIR=/jellyfin/deployment/win-x86 ARG ARTIFACT_DIR=/dist -ARG SDK_VERSION=2.2 +ARG SDK_VERSION=3.0 # Docker run environment ENV SOURCE_DIR=/jellyfin ENV ARTIFACT_DIR=/dist @@ -16,7 +16,7 @@ RUN apt-get update \ # Install dotnet repository # https://dotnet.microsoft.com/download/linux-package-manager/debian9/sdk-current -RUN wget https://download.visualstudio.microsoft.com/download/pr/228832ea-805f-45ab-8c88-fa36165701b9/16ce29a06031eeb09058dee94d6f5330/dotnet-sdk-2.2.401-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ +RUN wget https://download.visualstudio.microsoft.com/download/pr/4f51cfd8-311d-43fe-a887-c80b40358cfd/440d10dc2091b8d0f1a12b7124034e49/dotnet-sdk-3.0.101-linux-x64.tar.gz -O dotnet-sdk.tar.gz \ && mkdir -p dotnet-sdk \ && tar -xzf dotnet-sdk.tar.gz -C dotnet-sdk \ && ln -s $( pwd )/dotnet-sdk/dotnet /usr/bin/dotnet From 080b1069914cdca8a4e342ce9fa0a58578248420 Mon Sep 17 00:00:00 2001 From: Claus Vium Date: Tue, 26 Nov 2019 10:20:45 +0100 Subject: [PATCH 22/44] Update Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs Co-Authored-By: Vasily --- .../FirstTimeSetupOrElevatedRequirement.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs index a590155420..51ba637b60 100644 --- a/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs +++ b/Jellyfin.Api/Auth/FirstTimeSetupOrElevatedPolicy/FirstTimeSetupOrElevatedRequirement.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Authorization; namespace Jellyfin.Api.Auth.FirstTimeSetupOrElevatedPolicy { /// - /// The authorization requirement, requiring first time setup or elevated privileges, for the authorization handler. + /// The authorization requirement, requiring incomplete first time setup or elevated privileges, for the authorization handler. /// public class FirstTimeSetupOrElevatedRequirement : IAuthorizationRequirement { From 22f50de1fe32889be185f2c5065a0d743ceb3fbb Mon Sep 17 00:00:00 2001 From: Leo Verto Date: Mon, 25 Nov 2019 02:18:03 +0000 Subject: [PATCH 23/44] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index 888712709e..12bc16d746 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -23,7 +23,7 @@ "HeaderFavoriteEpisodes": "Lieblingsepisoden", "HeaderFavoriteShows": "Lieblingsserien", "HeaderFavoriteSongs": "Lieblingslieder", - "HeaderLiveTV": "Live-TV", + "HeaderLiveTV": "Live TV", "HeaderNextUp": "Als Nächstes", "HeaderRecordingGroups": "Aufnahme-Gruppen", "HomeVideos": "Heimvideos", From 1606706070d56e4ad60f740b6b3317b47791bc2b Mon Sep 17 00:00:00 2001 From: Mehmet Can Kanpolat Date: Mon, 25 Nov 2019 12:53:26 +0000 Subject: [PATCH 24/44] Translated using Weblate (Turkish) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/tr/ --- .../Localization/Core/tr.json | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json index 4768e3634e..24366b070a 100644 --- a/Emby.Server.Implementations/Localization/Core/tr.json +++ b/Emby.Server.Implementations/Localization/Core/tr.json @@ -45,46 +45,46 @@ "NameSeasonNumber": "Sezon {0}", "NameSeasonUnknown": "Bilinmeyen Sezon", "NewVersionIsAvailable": "Jellyfin Sunucusunun yeni bir versiyonu indirmek için hazır.", - "NotificationOptionApplicationUpdateAvailable": "Application update available", - "NotificationOptionApplicationUpdateInstalled": "Application update installed", + "NotificationOptionApplicationUpdateAvailable": "Uygulama güncellemesi mevcut", + "NotificationOptionApplicationUpdateInstalled": "Uygulama güncellemesi yüklendi", "NotificationOptionAudioPlayback": "Audio playback started", "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", "NotificationOptionCameraImageUploaded": "Camera image uploaded", - "NotificationOptionInstallationFailed": "Kurulum hatası", + "NotificationOptionInstallationFailed": "Yükleme başarısız oldu", "NotificationOptionNewLibraryContent": "New content added", - "NotificationOptionPluginError": "Plugin failure", - "NotificationOptionPluginInstalled": "Plugin installed", - "NotificationOptionPluginUninstalled": "Plugin uninstalled", - "NotificationOptionPluginUpdateInstalled": "Plugin update installed", - "NotificationOptionServerRestartRequired": "Server restart required", - "NotificationOptionTaskFailed": "Scheduled task failure", - "NotificationOptionUserLockedOut": "User locked out", + "NotificationOptionPluginError": "Eklenti hatası", + "NotificationOptionPluginInstalled": "Eklenti yüklendi", + "NotificationOptionPluginUninstalled": "Eklenti kaldırıldı", + "NotificationOptionPluginUpdateInstalled": "Eklenti güncellemesi yüklendi", + "NotificationOptionServerRestartRequired": "Sunucu yeniden başlatma gerekli", + "NotificationOptionTaskFailed": "Zamanlanmış görev hatası", + "NotificationOptionUserLockedOut": "Kullanıcı kitlendi", "NotificationOptionVideoPlayback": "Video playback started", "NotificationOptionVideoPlaybackStopped": "Video playback stopped", "Photos": "Fotoğraflar", "Playlists": "Çalma listeleri", - "Plugin": "Plugin", - "PluginInstalledWithName": "{0} was installed", - "PluginUninstalledWithName": "{0} was uninstalled", - "PluginUpdatedWithName": "{0} was updated", - "ProviderValue": "Provider: {0}", - "ScheduledTaskFailedWithName": "{0} failed", - "ScheduledTaskStartedWithName": "{0} started", - "ServerNameNeedsToBeRestarted": "{0} needs to be restarted", + "Plugin": "Eklenti", + "PluginInstalledWithName": "{0} yüklendi", + "PluginUninstalledWithName": "{0} kaldırıldı", + "PluginUpdatedWithName": "{0} güncellendi", + "ProviderValue": "Sağlayıcı: {0}", + "ScheduledTaskFailedWithName": "{0} başarısız oldu", + "ScheduledTaskStartedWithName": "{0} başladı", + "ServerNameNeedsToBeRestarted": "{0} yeniden başlatılması gerekiyor", "Shows": "Diziler", "Songs": "Şarkılar", - "StartupEmbyServerIsLoading": "Jellyfin Server is loading. Please try again shortly.", + "StartupEmbyServerIsLoading": "Jellyfin Sunucusu yükleniyor. Lütfen kısa süre sonra tekrar deneyin.", "SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}", "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}", "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", "Sync": "Eşitle", "System": "System", "TvShows": "TV Shows", - "User": "User", - "UserCreatedWithName": "User {0} has been created", - "UserDeletedWithName": "User {0} has been deleted", - "UserDownloadingItemWithValues": "{0} is downloading {1}", - "UserLockedOutWithName": "User {0} has been locked out", + "User": "Kullanıcı", + "UserCreatedWithName": "Kullanıcı {0} yaratıldı", + "UserDeletedWithName": "Kullanıcı {0} silindi", + "UserDownloadingItemWithValues": "{0} indiriliyor {1}", + "UserLockedOutWithName": "Kullanıcı {0} kitlendi", "UserOfflineFromDevice": "{0} has disconnected from {1}", "UserOnlineFromDevice": "{0} is online from {1}", "UserPasswordChangedWithName": "Password has been changed for user {0}", From 60691349a11f541958e0b2247c9abc13cb40c9fb Mon Sep 17 00:00:00 2001 From: excelite Date: Thu, 28 Nov 2019 11:20:46 +0100 Subject: [PATCH 25/44] added filesize limit for logfiles and a maximum logfile count --- Jellyfin.Server/Resources/Configuration/logging.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jellyfin.Server/Resources/Configuration/logging.json b/Jellyfin.Server/Resources/Configuration/logging.json index d169912774..e85ef05afd 100644 --- a/Jellyfin.Server/Resources/Configuration/logging.json +++ b/Jellyfin.Server/Resources/Configuration/logging.json @@ -17,6 +17,9 @@ "Args": { "path": "%JELLYFIN_LOG_DIR%//log_.log", "rollingInterval": "Day", + "retainedFileCountLimit": 3, + "rollOnFileSizeLimit": true, + "fileSizeLimitBytes": 100000000, "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] {Message}{NewLine}{Exception}" } } From 6f45d959512be3c8114681f819fdb1e2db1e978c Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Thu, 28 Nov 2019 17:46:06 +0100 Subject: [PATCH 26/44] Minor improvements to network code --- .../Networking/NetworkManager.cs | 40 ++++------------- .../SocketSharp/WebSocketSharpRequest.cs | 44 ++++++++++--------- MediaBrowser.Api/EnvironmentService.cs | 36 +++------------ MediaBrowser.Common/Net/INetworkManager.cs | 15 ------- 4 files changed, 39 insertions(+), 96 deletions(-) diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index 0b3567986d..1d8d3cf395 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -7,8 +7,6 @@ using System.Net.NetworkInformation; using System.Net.Sockets; using System.Threading.Tasks; using MediaBrowser.Common.Net; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Networking @@ -55,10 +53,7 @@ namespace Emby.Server.Implementations.Networking _macAddresses = null; } - if (NetworkChanged != null) - { - NetworkChanged(this, EventArgs.Empty); - } + NetworkChanged?.Invoke(this, EventArgs.Empty); } public IPAddress[] GetLocalIpAddresses(bool ignoreVirtualInterface = true) @@ -261,10 +256,10 @@ namespace Emby.Server.Implementations.Networking return true; } - if (normalizedSubnet.IndexOf('/') != -1) + if (normalizedSubnet.Contains('/', StringComparison.Ordinal)) { - var ipnetwork = IPNetwork.Parse(normalizedSubnet); - if (ipnetwork.Contains(address)) + var ipNetwork = IPNetwork.Parse(normalizedSubnet); + if (ipNetwork.Contains(address)) { return true; } @@ -455,9 +450,9 @@ namespace Emby.Server.Implementations.Networking public bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask) { - IPAddress network1 = GetNetworkAddress(address1, subnetMask); - IPAddress network2 = GetNetworkAddress(address2, subnetMask); - return network1.Equals(network2); + IPAddress network1 = GetNetworkAddress(address1, subnetMask); + IPAddress network2 = GetNetworkAddress(address2, subnetMask); + return network1.Equals(network2); } private IPAddress GetNetworkAddress(IPAddress address, IPAddress subnetMask) @@ -473,7 +468,7 @@ namespace Emby.Server.Implementations.Networking byte[] broadcastAddress = new byte[ipAdressBytes.Length]; for (int i = 0; i < broadcastAddress.Length; i++) { - broadcastAddress[i] = (byte)(ipAdressBytes[i] & (subnetMaskBytes[i])); + broadcastAddress[i] = (byte)(ipAdressBytes[i] & subnetMaskBytes[i]); } return new IPAddress(broadcastAddress); @@ -513,24 +508,5 @@ namespace Emby.Server.Implementations.Networking return null; } - - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{NetworkShare}. - public virtual IEnumerable GetNetworkShares(string path) - { - return new List(); - } - - /// - /// Gets available devices within the domain - /// - /// PC's in the Domain - public virtual IEnumerable GetNetworkDevices() - { - return new List(); - } } } diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index 690ba0be4a..a1d41c8958 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -14,9 +14,9 @@ namespace Emby.Server.Implementations.SocketSharp { public class WebSocketSharpRequest : IHttpRequest { - public const string FormUrlEncoded = "application/x-www-form-urlencoded"; - public const string MultiPartFormData = "multipart/form-data"; - public const string Soap11 = "text/xml; charset=utf-8"; + private const string FormUrlEncoded = "application/x-www-form-urlencoded"; + private const string MultiPartFormData = "multipart/form-data"; + private const string Soap11 = "text/xml; charset=utf-8"; private string _remoteIp; private Dictionary _items; @@ -77,7 +77,7 @@ namespace Emby.Server.Implementations.SocketSharp get => _responseContentType ?? (_responseContentType = GetResponseContentType(Request)); - set => this._responseContentType = value; + set => _responseContentType = value; } public string PathInfo => Request.Path.Value; @@ -90,7 +90,6 @@ namespace Emby.Server.Implementations.SocketSharp public bool IsLocal => Request.HttpContext.Connection.LocalIpAddress.Equals(Request.HttpContext.Connection.RemoteIpAddress); - public string HttpMethod => Request.Method; public string Verb => HttpMethod; @@ -123,24 +122,29 @@ namespace Emby.Server.Implementations.SocketSharp return specifiedContentType; } - const string serverDefaultContentType = "application/json"; + const string ServerDefaultContentType = "application/json"; var acceptContentTypes = httpReq.Headers.GetCommaSeparatedValues(HeaderNames.Accept); string defaultContentType = null; if (HasAnyOfContentTypes(httpReq, FormUrlEncoded, MultiPartFormData)) { - defaultContentType = serverDefaultContentType; + defaultContentType = ServerDefaultContentType; } var acceptsAnything = false; var hasDefaultContentType = defaultContentType != null; if (acceptContentTypes != null) { - foreach (var acceptsType in acceptContentTypes) + foreach (ReadOnlySpan acceptsType in acceptContentTypes) { - // TODO: @bond move to Span when Span.Split lands - // https://github.com/dotnet/corefx/issues/26528 - var contentType = acceptsType?.Split(';')[0].Trim(); + ReadOnlySpan contentType = acceptsType; + var index = contentType.IndexOf(';'); + if (index != -1) + { + contentType = contentType.Slice(0, index); + } + + contentType = contentType.Trim(); acceptsAnything = contentType.Equals("*/*", StringComparison.OrdinalIgnoreCase); if (acceptsAnything) @@ -157,7 +161,7 @@ namespace Emby.Server.Implementations.SocketSharp } else { - return serverDefaultContentType; + return ServerDefaultContentType; } } } @@ -168,7 +172,7 @@ namespace Emby.Server.Implementations.SocketSharp } // We could also send a '406 Not Acceptable', but this is allowed also - return serverDefaultContentType; + return ServerDefaultContentType; } public static bool HasAnyOfContentTypes(HttpRequest request, params string[] contentTypes) @@ -196,12 +200,12 @@ namespace Emby.Server.Implementations.SocketSharp private static string GetQueryStringContentType(HttpRequest httpReq) { - ReadOnlySpan format = httpReq.Query["format"].ToString().AsSpan(); + ReadOnlySpan format = httpReq.Query["format"].ToString(); if (format == null) { - const int formatMaxLength = 4; - ReadOnlySpan pi = httpReq.Path.ToString().AsSpan(); - if (pi == null || pi.Length <= formatMaxLength) + const int FormatMaxLength = 4; + ReadOnlySpan pi = httpReq.Path.ToString(); + if (pi == null || pi.Length <= FormatMaxLength) { return null; } @@ -212,18 +216,18 @@ namespace Emby.Server.Implementations.SocketSharp } format = LeftPart(pi, '/'); - if (format.Length > formatMaxLength) + if (format.Length > FormatMaxLength) { return null; } } format = LeftPart(format, '.'); - if (format.Contains("json".AsSpan(), StringComparison.OrdinalIgnoreCase)) + if (format.Contains("json", StringComparison.OrdinalIgnoreCase)) { return "application/json"; } - else if (format.Contains("xml".AsSpan(), StringComparison.OrdinalIgnoreCase)) + else if (format.Contains("xml", StringComparison.OrdinalIgnoreCase)) { return "application/xml"; } diff --git a/MediaBrowser.Api/EnvironmentService.cs b/MediaBrowser.Api/EnvironmentService.cs index f4813e7132..a63ef9f053 100644 --- a/MediaBrowser.Api/EnvironmentService.cs +++ b/MediaBrowser.Api/EnvironmentService.cs @@ -52,6 +52,7 @@ namespace MediaBrowser.Api public bool? IsFile { get; set; } } + [Obsolete] [Route("/Environment/NetworkShares", "GET", Summary = "Gets shares from a network device")] public class GetNetworkShares : IReturn> { @@ -192,22 +193,18 @@ namespace MediaBrowser.Api var networkPrefix = UncSeparatorString + UncSeparatorString; - if (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) && path.LastIndexOf(UncSeparator) == 1) + if (path.StartsWith(networkPrefix, StringComparison.OrdinalIgnoreCase) + && path.LastIndexOf(UncSeparator) == 1) { - return ToOptimizedResult(GetNetworkShares(path).OrderBy(i => i.Path).ToList()); + return ToOptimizedResult(Array.Empty()); } return ToOptimizedResult(GetFileSystemEntries(request).ToList()); } + [Obsolete] public object Get(GetNetworkShares request) - { - var path = request.Path; - - var shares = GetNetworkShares(path).OrderBy(i => i.Path).ToList(); - - return ToOptimizedResult(shares); - } + => ToOptimizedResult(Array.Empty()); /// /// Gets the specified request. @@ -241,26 +238,7 @@ namespace MediaBrowser.Api /// The request. /// System.Object. public object Get(GetNetworkDevices request) - { - var result = _networkManager.GetNetworkDevices().ToList(); - - return ToOptimizedResult(result); - } - - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{FileSystemEntryInfo}. - private IEnumerable GetNetworkShares(string path) - { - return _networkManager.GetNetworkShares(path).Where(s => s.ShareType == NetworkShareType.Disk).Select(c => new FileSystemEntryInfo - { - Name = c.Name, - Path = Path.Combine(path, c.Name), - Type = FileSystemEntryType.NetworkShare - }); - } + => ToOptimizedResult(Array.Empty()); /// /// Gets the file system entries. diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index 97504a471f..0b99dc9103 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -4,8 +4,6 @@ using System; using System.Collections.Generic; using System.Net; using System.Net.NetworkInformation; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.Net; namespace MediaBrowser.Common.Net { @@ -36,19 +34,6 @@ namespace MediaBrowser.Common.Net /// true if [is in private address space] [the specified endpoint]; otherwise, false. bool IsInPrivateAddressSpace(string endpoint); - /// - /// Gets the network shares. - /// - /// The path. - /// IEnumerable{NetworkShare}. - IEnumerable GetNetworkShares(string path); - - /// - /// Gets available devices within the domain - /// - /// PC's in the Domain - IEnumerable GetNetworkDevices(); - /// /// Determines whether [is in local network] [the specified endpoint]. /// From 12dd2c51a7182898d2529a73676214e1f0dbc7a3 Mon Sep 17 00:00:00 2001 From: excelite Date: Fri, 29 Nov 2019 23:03:59 +0100 Subject: [PATCH 27/44] added required nuget package to enable serilog based centralized logging in gelf fromat --- Jellyfin.Server/Jellyfin.Server.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/Jellyfin.Server/Jellyfin.Server.csproj b/Jellyfin.Server/Jellyfin.Server.csproj index 7d97a1f20f..110028176c 100644 --- a/Jellyfin.Server/Jellyfin.Server.csproj +++ b/Jellyfin.Server/Jellyfin.Server.csproj @@ -46,6 +46,7 @@ + From be14b91f2371ccaf5a93dde80dbeedcda623137e Mon Sep 17 00:00:00 2001 From: Mehmet Can Kanpolat Date: Wed, 27 Nov 2019 16:41:49 +0000 Subject: [PATCH 28/44] Translated using Weblate (Turkish) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/tr/ --- .../Localization/Core/tr.json | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/tr.json b/Emby.Server.Implementations/Localization/Core/tr.json index 24366b070a..eb1c2623f7 100644 --- a/Emby.Server.Implementations/Localization/Core/tr.json +++ b/Emby.Server.Implementations/Localization/Core/tr.json @@ -25,33 +25,33 @@ "HeaderFavoriteSongs": "Favori Şarkılar", "HeaderLiveTV": "Canlı TV", "HeaderNextUp": "Sonraki hafta", - "HeaderRecordingGroups": "Recording Groups", - "HomeVideos": "Home videos", - "Inherit": "Inherit", - "ItemAddedWithName": "{0} was added to the library", - "ItemRemovedWithName": "{0} was removed from the library", - "LabelIpAddressValue": "Ip adresi: {0}", + "HeaderRecordingGroups": "Kayıt Grupları", + "HomeVideos": "Ev videoları", + "Inherit": "Devral", + "ItemAddedWithName": "{0} kütüphaneye eklendi", + "ItemRemovedWithName": "{0} kütüphaneden silindi", + "LabelIpAddressValue": "IP adresi: {0}", "LabelRunningTimeValue": "Çalışma süresi: {0}", - "Latest": "Latest", + "Latest": "En son", "MessageApplicationUpdated": "Jellyfin Sunucusu güncellendi", - "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}", - "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated", - "MessageServerConfigurationUpdated": "Server configuration has been updated", - "MixedContent": "Mixed content", + "MessageApplicationUpdatedTo": "Jellyfin Sunucusu {0} olarak güncellendi", + "MessageNamedServerConfigurationUpdatedWithValue": "Sunucu ayarları kısım {0} güncellendi", + "MessageServerConfigurationUpdated": "Sunucu ayarları güncellendi", + "MixedContent": "Karışık içerik", "Movies": "Filmler", "Music": "Müzik", "MusicVideos": "Müzik videoları", - "NameInstallFailed": "{0} kurulum başarısız", + "NameInstallFailed": "{0} kurulumu başarısız", "NameSeasonNumber": "Sezon {0}", "NameSeasonUnknown": "Bilinmeyen Sezon", "NewVersionIsAvailable": "Jellyfin Sunucusunun yeni bir versiyonu indirmek için hazır.", "NotificationOptionApplicationUpdateAvailable": "Uygulama güncellemesi mevcut", "NotificationOptionApplicationUpdateInstalled": "Uygulama güncellemesi yüklendi", - "NotificationOptionAudioPlayback": "Audio playback started", - "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", - "NotificationOptionCameraImageUploaded": "Camera image uploaded", + "NotificationOptionAudioPlayback": "Ses çalma başladı", + "NotificationOptionAudioPlaybackStopped": "Ses çalma durduruldu", + "NotificationOptionCameraImageUploaded": "Kamera fotoğrafı yüklendi", "NotificationOptionInstallationFailed": "Yükleme başarısız oldu", - "NotificationOptionNewLibraryContent": "New content added", + "NotificationOptionNewLibraryContent": "Yeni içerik eklendi", "NotificationOptionPluginError": "Eklenti hatası", "NotificationOptionPluginInstalled": "Eklenti yüklendi", "NotificationOptionPluginUninstalled": "Eklenti kaldırıldı", @@ -59,8 +59,8 @@ "NotificationOptionServerRestartRequired": "Sunucu yeniden başlatma gerekli", "NotificationOptionTaskFailed": "Zamanlanmış görev hatası", "NotificationOptionUserLockedOut": "Kullanıcı kitlendi", - "NotificationOptionVideoPlayback": "Video playback started", - "NotificationOptionVideoPlaybackStopped": "Video playback stopped", + "NotificationOptionVideoPlayback": "Video oynatma başladı", + "NotificationOptionVideoPlaybackStopped": "Video oynatma durduruldu", "Photos": "Fotoğraflar", "Playlists": "Çalma listeleri", "Plugin": "Eklenti", @@ -75,23 +75,23 @@ "Songs": "Şarkılar", "StartupEmbyServerIsLoading": "Jellyfin Sunucusu yükleniyor. Lütfen kısa süre sonra tekrar deneyin.", "SubtitleDownloadFailureForItem": "Subtitles failed to download for {0}", - "SubtitleDownloadFailureFromForItem": "Subtitles failed to download from {0} for {1}", - "SubtitlesDownloadedForItem": "Subtitles downloaded for {0}", + "SubtitleDownloadFailureFromForItem": "{1} için alt yazılar {0} 'dan indirilemedi", + "SubtitlesDownloadedForItem": "{0} için altyazılar indirildi", "Sync": "Eşitle", - "System": "System", - "TvShows": "TV Shows", + "System": "Sistem", + "TvShows": "Diziler", "User": "Kullanıcı", - "UserCreatedWithName": "Kullanıcı {0} yaratıldı", + "UserCreatedWithName": "{0} kullanıcısı oluşturuldu", "UserDeletedWithName": "Kullanıcı {0} silindi", "UserDownloadingItemWithValues": "{0} indiriliyor {1}", "UserLockedOutWithName": "Kullanıcı {0} kitlendi", - "UserOfflineFromDevice": "{0} has disconnected from {1}", - "UserOnlineFromDevice": "{0} is online from {1}", - "UserPasswordChangedWithName": "Password has been changed for user {0}", - "UserPolicyUpdatedWithName": "User policy has been updated for {0}", - "UserStartedPlayingItemWithValues": "{0} is playing {1} on {2}", - "UserStoppedPlayingItemWithValues": "{0} has finished playing {1} on {2}", - "ValueHasBeenAddedToLibrary": "{0} has been added to your media library", - "ValueSpecialEpisodeName": "Özel -{0}", - "VersionNumber": "Version {0}" + "UserOfflineFromDevice": "{0}, {1} ile bağlantısı kesildi", + "UserOnlineFromDevice": "{0}, {1} çevrimiçi", + "UserPasswordChangedWithName": "{0} kullanıcısı için şifre değiştirildi", + "UserPolicyUpdatedWithName": "Kullanıcı politikası {0} için güncellendi", + "UserStartedPlayingItemWithValues": "{0}, {2} cihazında {1} izliyor", + "UserStoppedPlayingItemWithValues": "{0}, {2} cihazında {1} izlemeyi bitirdi", + "ValueHasBeenAddedToLibrary": "Medya kitaplığınıza {0} eklendi", + "ValueSpecialEpisodeName": "Özel - {0}", + "VersionNumber": "Versiyon {0}" } From 28f71b445fd7bdca63f29791e27da8224989d025 Mon Sep 17 00:00:00 2001 From: penguinfuko Date: Thu, 28 Nov 2019 05:21:20 +0000 Subject: [PATCH 29/44] Translated using Weblate (Chinese (Traditional)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/zh_Hant/ --- Emby.Server.Implementations/Localization/Core/zh-TW.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/zh-TW.json b/Emby.Server.Implementations/Localization/Core/zh-TW.json index 293fc28a86..33bdbfb989 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-TW.json +++ b/Emby.Server.Implementations/Localization/Core/zh-TW.json @@ -1,6 +1,6 @@ { "Albums": "專輯", - "AppDeviceValues": "應用: {0}, 裝置: {1}", + "AppDeviceValues": "軟體: {0}, 裝置: {1}", "Application": "應用程式", "Artists": "演出者", "AuthenticationSucceededWithUserName": "{0} 成功授權", From 84c136b1f24096a726f41aaf89091206b76f9c00 Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Sun, 1 Dec 2019 19:30:18 +0100 Subject: [PATCH 30/44] Update Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs Co-Authored-By: Claus Vium --- .../SocketSharp/WebSocketSharpRequest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index a1d41c8958..081f61ef93 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -122,7 +122,7 @@ namespace Emby.Server.Implementations.SocketSharp return specifiedContentType; } - const string ServerDefaultContentType = "application/json"; + const string ServerDefaultContentType = MediaTypeNames.Application.Json; var acceptContentTypes = httpReq.Headers.GetCommaSeparatedValues(HeaderNames.Accept); string defaultContentType = null; From 3b7b8eba4c25692d4e2fb950e33c5463d3f0555e Mon Sep 17 00:00:00 2001 From: EscAbe Date: Sun, 1 Dec 2019 20:50:24 +0100 Subject: [PATCH 31/44] Fix for #2088 --- MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs index eaebc13e32..fc7f12b1a8 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbEpisodeImageProvider.cs @@ -57,7 +57,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB { IndexNumber = episode.IndexNumber.Value, ParentIndexNumber = episode.ParentIndexNumber.Value, - SeriesProviderIds = series.ProviderIds + SeriesProviderIds = series.ProviderIds, + SeriesDisplayOrder = series.DisplayOrder }; string episodeTvdbId = await _tvDbClientManager .GetEpisodeTvdbId(episodeInfo, language, cancellationToken).ConfigureAwait(false); From a7461f3ba7488b18eab969f344c0045ef4893f21 Mon Sep 17 00:00:00 2001 From: KingsFourze Date: Sun, 1 Dec 2019 03:18:36 +0000 Subject: [PATCH 32/44] Translated using Weblate (Chinese (Hong Kong)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/zh_Hant_HK/ --- Emby.Server.Implementations/Localization/Core/zh-HK.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/zh-HK.json b/Emby.Server.Implementations/Localization/Core/zh-HK.json index 387fc2b92b..33fcb2d37c 100644 --- a/Emby.Server.Implementations/Localization/Core/zh-HK.json +++ b/Emby.Server.Implementations/Localization/Core/zh-HK.json @@ -2,7 +2,7 @@ "Albums": "Albums", "AppDeviceValues": "App: {0}, Device: {1}", "Application": "Application", - "Artists": "Artists", + "Artists": "藝人", "AuthenticationSucceededWithUserName": "{0} successfully authenticated", "Books": "Books", "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", From caca2b31fe831ae33bea36128655ed587837f40e Mon Sep 17 00:00:00 2001 From: Bond-009 Date: Tue, 3 Dec 2019 10:55:22 +0100 Subject: [PATCH 33/44] Fix build --- Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index 081f61ef93..1781df8b51 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Net; +using System.Net.Mime; using MediaBrowser.Common.Net; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; From df10cf8012a64a931b2d48c07a475e33414f5edf Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 12:59:32 +0000 Subject: [PATCH 34/44] Added translation using Weblate (Afrikaans) --- Emby.Server.Implementations/Localization/Core/af.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 Emby.Server.Implementations/Localization/Core/af.json diff --git a/Emby.Server.Implementations/Localization/Core/af.json b/Emby.Server.Implementations/Localization/Core/af.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/Emby.Server.Implementations/Localization/Core/af.json @@ -0,0 +1 @@ +{} From 903752b77b222a4a5113f2f679771d0b64ea9436 Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 13:05:03 +0000 Subject: [PATCH 35/44] Translated using Weblate (English (United States)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/en_US/ --- Emby.Server.Implementations/Localization/Core/en-US.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index aa855ed21f..dbbf5b27b6 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -8,9 +8,9 @@ "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", "Channels": "Channels", "ChapterNameValue": "Chapter {0}", - "Collections": "Collections", - "DeviceOfflineWithName": "{0} has disconnected", - "DeviceOnlineWithName": "{0} is connected", + "Collections": "Versamelings", + "DeviceOfflineWithName": "{0} het afgesluit", + "DeviceOnlineWithName": "{0} is verbind", "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", "Favorites": "Favorites", "Folders": "Folders", From f7d71a2bc722a178c967ac736c4c2b920eefa10f Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 4 Dec 2019 21:47:01 +0100 Subject: [PATCH 36/44] Remove unused fields and properties --- .../ServerApplicationPaths.cs | 17 +++++------------ .../IServerApplicationPaths.cs | 17 +++++------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Emby.Server.Implementations/ServerApplicationPaths.cs b/Emby.Server.Implementations/ServerApplicationPaths.cs index 4b8298abbd..2f57c97a13 100644 --- a/Emby.Server.Implementations/ServerApplicationPaths.cs +++ b/Emby.Server.Implementations/ServerApplicationPaths.cs @@ -1,4 +1,3 @@ -using System; using System.IO; using Emby.Server.Implementations.AppBase; using MediaBrowser.Controller; @@ -10,8 +9,6 @@ namespace Emby.Server.Implementations /// public class ServerApplicationPaths : BaseApplicationPaths, IServerApplicationPaths { - private string _defaultTranscodePath; - private string _transcodePath; private string _internalMetadataPath; /// @@ -23,7 +20,8 @@ namespace Emby.Server.Implementations string configurationDirectoryPath, string cacheDirectoryPath, string webDirectoryPath) - : base(programDataPath, + : base( + programDataPath, logDirectoryPath, configurationDirectoryPath, cacheDirectoryPath, @@ -31,8 +29,6 @@ namespace Emby.Server.Implementations { } - public string ApplicationResourcesPath { get; } = AppContext.BaseDirectory; - /// /// Gets the path to the base root media directory. /// @@ -45,18 +41,13 @@ namespace Emby.Server.Implementations /// The default user views path. public string DefaultUserViewsPath => Path.Combine(RootFolderPath, "default"); - /// - /// Gets the path to localization data. - /// - /// The localization path. - public string LocalizationPath => Path.Combine(ProgramDataPath, "localization"); - /// /// Gets the path to the People directory. /// /// The people path. public string PeoplePath => Path.Combine(InternalMetadataPath, "People"); + /// public string ArtistsPath => Path.Combine(InternalMetadataPath, "artists"); /// @@ -107,12 +98,14 @@ namespace Emby.Server.Implementations /// The user configuration directory path. public string UserConfigurationDirectoryPath => Path.Combine(ConfigurationDirectoryPath, "users"); + /// public string InternalMetadataPath { get => _internalMetadataPath ?? (_internalMetadataPath = Path.Combine(DataPath, "metadata")); set => _internalMetadataPath = value; } + /// public string VirtualInternalMetadataPath { get; } = "%MetadataPath%"; } } diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index 56e7e4e47a..5d7c60910a 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -10,24 +10,12 @@ namespace MediaBrowser.Controller /// The root folder path. string RootFolderPath { get; } - /// - /// Gets the application resources path. This is the path to the folder containing resources that are deployed as part of the application - /// - /// The application resources path. - string ApplicationResourcesPath { get; } - /// /// Gets the path to the default user view directory. Used if no specific user view is defined. /// /// The default user views path. string DefaultUserViewsPath { get; } - /// - /// Gets the path to localization data. - /// - /// The localization path. - string LocalizationPath { get; } - /// /// Gets the path to the People directory /// @@ -87,8 +75,13 @@ namespace MediaBrowser.Controller /// /// The internal metadata path. string InternalMetadataPath { get; } + string VirtualInternalMetadataPath { get; } + /// + /// Gets the path to the artists directory. + /// + /// The artists path. string ArtistsPath { get; } } } From 4a0df15bbd7f4cb87eba2e0a2ff39b74abd083fe Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 4 Dec 2019 22:18:37 +0100 Subject: [PATCH 37/44] Fix GetTranscodePath function and cache path update logline * GetTranscodePath returned an empty string after the option was left blank in the web UI * Unified the log style for all paths --- .../AppBase/BaseConfigurationManager.cs | 10 ++++++---- .../Configuration/EncodingConfigurationExtensions.cs | 11 +++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs index 67bb25b077..2a5d56c603 100644 --- a/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs +++ b/Emby.Server.Implementations/AppBase/BaseConfigurationManager.cs @@ -84,6 +84,7 @@ namespace Emby.Server.Implementations.AppBase /// /// The logger. protected ILogger Logger { get; private set; } + /// /// Gets the XML serializer. /// @@ -97,7 +98,7 @@ namespace Emby.Server.Implementations.AppBase public IApplicationPaths CommonApplicationPaths { get; private set; } /// - /// Gets the system configuration. + /// Gets or sets the system configuration. /// /// The configuration. public BaseApplicationConfiguration CommonConfiguration @@ -123,6 +124,7 @@ namespace Emby.Server.Implementations.AppBase return _configuration; } } + protected set { _configuration = value; @@ -215,7 +217,7 @@ namespace Emby.Server.Implementations.AppBase cachePath = CommonConfiguration.CachePath; } - Logger.LogInformation("Setting cache path to " + cachePath); + Logger.LogInformation("Setting cache path: {Path}", cachePath); ((BaseApplicationPaths)CommonApplicationPaths).CachePath = cachePath; } @@ -223,7 +225,7 @@ namespace Emby.Server.Implementations.AppBase /// Replaces the cache path. /// /// The new configuration. - /// + /// The new cache path doesn't exist. private void ValidateCachePath(BaseApplicationConfiguration newConfig) { var newPath = newConfig.CachePath; @@ -234,7 +236,7 @@ namespace Emby.Server.Implementations.AppBase // Validate if (!Directory.Exists(newPath)) { - throw new FileNotFoundException( + throw new DirectoryNotFoundException( string.Format( CultureInfo.InvariantCulture, "{0} does not exist.", diff --git a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs index 2bf1f6bc8c..ccf9658988 100644 --- a/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs +++ b/MediaBrowser.Common/Configuration/EncodingConfigurationExtensions.cs @@ -22,7 +22,14 @@ namespace MediaBrowser.Common.Configuration /// The Configuration manager. /// The transcoding temp path. public static string GetTranscodePath(this IConfigurationManager configurationManager) - => configurationManager.GetEncodingOptions().TranscodingTempPath - ?? Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes"); + { + var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath; + if (string.IsNullOrEmpty(transcodingTempPath)) + { + return Path.Combine(configurationManager.CommonApplicationPaths.ProgramDataPath, "transcodes"); + } + + return transcodingTempPath; + } } } From 383733044ff6220213c355ee950b9390976fbb2d Mon Sep 17 00:00:00 2001 From: woodmichl Date: Tue, 3 Dec 2019 20:30:12 +0000 Subject: [PATCH 38/44] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index 12bc16d746..d22195ce23 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -10,7 +10,7 @@ "ChapterNameValue": "Kapitel {0}", "Collections": "Sammlungen", "DeviceOfflineWithName": "{0} wurde getrennt", - "DeviceOnlineWithName": "{0} hat sich verbunden", + "DeviceOnlineWithName": "{0} ist verbunden", "FailedLoginAttemptWithUserName": "Fehlgeschlagener Anmeldeversuch von {0}", "Favorites": "Favoriten", "Folders": "Verzeichnisse", From 7d2f066cd42fe36b7d073d894cf75533c315d18c Mon Sep 17 00:00:00 2001 From: Dominik Date: Thu, 5 Dec 2019 08:56:43 +0000 Subject: [PATCH 39/44] Translated using Weblate (German) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/de/ --- Emby.Server.Implementations/Localization/Core/de.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/de.json b/Emby.Server.Implementations/Localization/Core/de.json index d22195ce23..019736c471 100644 --- a/Emby.Server.Implementations/Localization/Core/de.json +++ b/Emby.Server.Implementations/Localization/Core/de.json @@ -3,7 +3,7 @@ "AppDeviceValues": "App: {0}, Gerät: {1}", "Application": "Anwendung", "Artists": "Interpreten", - "AuthenticationSucceededWithUserName": "{0} hat sich angemeldet", + "AuthenticationSucceededWithUserName": "{0} hat sich erfolgreich angemeldet", "Books": "Bücher", "CameraImageUploadedFrom": "Ein neues Foto wurde hochgeladen von {0}", "Channels": "Kanäle", From 5234c686e75796adbab8110d7a86820be04873ab Mon Sep 17 00:00:00 2001 From: TheGoose Date: Wed, 4 Dec 2019 07:25:38 +0000 Subject: [PATCH 40/44] Translated using Weblate (English (United States)) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/en_US/ --- Emby.Server.Implementations/Localization/Core/en-US.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.json index dbbf5b27b6..aa855ed21f 100644 --- a/Emby.Server.Implementations/Localization/Core/en-US.json +++ b/Emby.Server.Implementations/Localization/Core/en-US.json @@ -8,9 +8,9 @@ "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", "Channels": "Channels", "ChapterNameValue": "Chapter {0}", - "Collections": "Versamelings", - "DeviceOfflineWithName": "{0} het afgesluit", - "DeviceOnlineWithName": "{0} is verbind", + "Collections": "Collections", + "DeviceOfflineWithName": "{0} has disconnected", + "DeviceOnlineWithName": "{0} is connected", "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", "Favorites": "Favorites", "Folders": "Folders", From 9144c84dc9b62845a1e9aa680048e03f8e5c3ad8 Mon Sep 17 00:00:00 2001 From: bugthug Date: Wed, 4 Dec 2019 18:32:38 +0000 Subject: [PATCH 41/44] Translated using Weblate (Hebrew) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/he/ --- .../Localization/Core/he.json | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json index 0ed998c4bd..3e96fa482d 100644 --- a/Emby.Server.Implementations/Localization/Core/he.json +++ b/Emby.Server.Implementations/Localization/Core/he.json @@ -5,37 +5,37 @@ "Artists": "אמנים", "AuthenticationSucceededWithUserName": "{0} successfully authenticated", "Books": "ספרים", - "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", - "Channels": "Channels", - "ChapterNameValue": "Chapter {0}", - "Collections": "Collections", - "DeviceOfflineWithName": "{0} has disconnected", - "DeviceOnlineWithName": "{0} is connected", - "FailedLoginAttemptWithUserName": "Failed login attempt from {0}", - "Favorites": "Favorites", - "Folders": "Folders", + "CameraImageUploadedFrom": "תמונה חדשה הועלתה מ{0}", + "Channels": "ערוצים", + "ChapterNameValue": "פרק {0}", + "Collections": "קולקציות", + "DeviceOfflineWithName": "{0} התנתק", + "DeviceOnlineWithName": "{0} מחובר", + "FailedLoginAttemptWithUserName": "ניסיון כניסה שגוי מ{0}", + "Favorites": "אהובים", + "Folders": "תיקיות", "Genres": "ז'אנרים", - "HeaderAlbumArtists": "Album Artists", - "HeaderCameraUploads": "Camera Uploads", - "HeaderContinueWatching": "המשך בצפייה", - "HeaderFavoriteAlbums": "Favorite Albums", - "HeaderFavoriteArtists": "Favorite Artists", - "HeaderFavoriteEpisodes": "Favorite Episodes", - "HeaderFavoriteShows": "Favorite Shows", - "HeaderFavoriteSongs": "Favorite Songs", - "HeaderLiveTV": "Live TV", - "HeaderNextUp": "Next Up", + "HeaderAlbumArtists": "אמני האלבום", + "HeaderCameraUploads": "העלאות ממצלמה", + "HeaderContinueWatching": "המשך לצפות", + "HeaderFavoriteAlbums": "אלבומים שאהבתי", + "HeaderFavoriteArtists": "אמנים שאהבתי", + "HeaderFavoriteEpisodes": "פרקים אהובים", + "HeaderFavoriteShows": "תוכניות אהובות", + "HeaderFavoriteSongs": "שירים שאהבתי", + "HeaderLiveTV": "טלוויזיה בשידור חי", + "HeaderNextUp": "הבא", "HeaderRecordingGroups": "קבוצות הקלטה", - "HomeVideos": "Home videos", - "Inherit": "Inherit", + "HomeVideos": "סרטונים בייתים", + "Inherit": "הורש", "ItemAddedWithName": "{0} was added to the library", - "ItemRemovedWithName": "{0} was removed from the library", + "ItemRemovedWithName": "{0} נמחק מהספרייה", "LabelIpAddressValue": "Ip address: {0}", - "LabelRunningTimeValue": "Running time: {0}", + "LabelRunningTimeValue": "משך צפייה: {0}", "Latest": "אחרון", - "MessageApplicationUpdated": "Jellyfin Server has been updated", - "MessageApplicationUpdatedTo": "Jellyfin Server has been updated to {0}", - "MessageNamedServerConfigurationUpdatedWithValue": "Server configuration section {0} has been updated", + "MessageApplicationUpdated": "שרת הJellyfin עודכן", + "MessageApplicationUpdatedTo": "שרת הJellyfin עודכן לגרסא {0}", + "MessageNamedServerConfigurationUpdatedWithValue": "הגדרת השרת {0} שונתה", "MessageServerConfigurationUpdated": "Server configuration has been updated", "MixedContent": "תוכן מעורב", "Movies": "סרטים", From fc4bbee39ff4a7a9daf79c528837551a293d020c Mon Sep 17 00:00:00 2001 From: Yuval Pecht Date: Thu, 5 Dec 2019 08:05:29 +0000 Subject: [PATCH 42/44] Translated using Weblate (Hebrew) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/he/ --- Emby.Server.Implementations/Localization/Core/he.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/he.json b/Emby.Server.Implementations/Localization/Core/he.json index 3e96fa482d..b08c8966e2 100644 --- a/Emby.Server.Implementations/Localization/Core/he.json +++ b/Emby.Server.Implementations/Localization/Core/he.json @@ -1,9 +1,9 @@ { "Albums": "אלבומים", - "AppDeviceValues": "App: {0}, Device: {1}", + "AppDeviceValues": "יישום: {0}, מכשיר: {1}", "Application": "אפליקציה", "Artists": "אמנים", - "AuthenticationSucceededWithUserName": "{0} successfully authenticated", + "AuthenticationSucceededWithUserName": "{0} זוהה בהצלחה", "Books": "ספרים", "CameraImageUploadedFrom": "תמונה חדשה הועלתה מ{0}", "Channels": "ערוצים", @@ -30,7 +30,7 @@ "Inherit": "הורש", "ItemAddedWithName": "{0} was added to the library", "ItemRemovedWithName": "{0} נמחק מהספרייה", - "LabelIpAddressValue": "Ip address: {0}", + "LabelIpAddressValue": "Ip כתובת: {0}", "LabelRunningTimeValue": "משך צפייה: {0}", "Latest": "אחרון", "MessageApplicationUpdated": "שרת הJellyfin עודכן", @@ -50,7 +50,7 @@ "NotificationOptionAudioPlayback": "Audio playback started", "NotificationOptionAudioPlaybackStopped": "Audio playback stopped", "NotificationOptionCameraImageUploaded": "Camera image uploaded", - "NotificationOptionInstallationFailed": "Installation failure", + "NotificationOptionInstallationFailed": "התקנה נכשלה", "NotificationOptionNewLibraryContent": "New content added", "NotificationOptionPluginError": "Plugin failure", "NotificationOptionPluginInstalled": "Plugin installed", From fccc90ae1a7ebd0f1a24b407e6bf8ff82d6357e2 Mon Sep 17 00:00:00 2001 From: Pavel Sochor Date: Thu, 5 Dec 2019 08:22:23 +0000 Subject: [PATCH 43/44] Translated using Weblate (Slovak) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/sk/ --- Emby.Server.Implementations/Localization/Core/sk.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/sk.json b/Emby.Server.Implementations/Localization/Core/sk.json index 6eade79429..75eecbe3e0 100644 --- a/Emby.Server.Implementations/Localization/Core/sk.json +++ b/Emby.Server.Implementations/Localization/Core/sk.json @@ -5,7 +5,7 @@ "Artists": "Umelci", "AuthenticationSucceededWithUserName": "{0} úspešne overený", "Books": "Knihy", - "CameraImageUploadedFrom": "A new camera image has been uploaded from {0}", + "CameraImageUploadedFrom": "Z {0} bola nahraná nová fotografia", "Channels": "Kanály", "ChapterNameValue": "Kapitola {0}", "Collections": "Zbierky", @@ -15,9 +15,9 @@ "Favorites": "Obľúbené", "Folders": "Priečinky", "Genres": "Žánre", - "HeaderAlbumArtists": "Album Artists", + "HeaderAlbumArtists": "Albumy umelcov", "HeaderCameraUploads": "Nahrané fotografie", - "HeaderContinueWatching": "Pokračujte v pozeraní", + "HeaderContinueWatching": "Pokračovať v pozeraní", "HeaderFavoriteAlbums": "Obľúbené albumy", "HeaderFavoriteArtists": "Obľúbení umelci", "HeaderFavoriteEpisodes": "Obľúbené epizódy", From 82575db6620fa7ddbcfd908d9575b85eeeb4ad07 Mon Sep 17 00:00:00 2001 From: WtK0040 Date: Tue, 3 Dec 2019 13:00:59 +0000 Subject: [PATCH 44/44] Translated using Weblate (Afrikaans) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/af/ --- .../Localization/Core/af.json | 97 ++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Localization/Core/af.json b/Emby.Server.Implementations/Localization/Core/af.json index 0967ef424b..dcec268017 100644 --- a/Emby.Server.Implementations/Localization/Core/af.json +++ b/Emby.Server.Implementations/Localization/Core/af.json @@ -1 +1,96 @@ -{} +{ + "Artists": "Kunstenare", + "Channels": "Kanale", + "Folders": "Fouers", + "Favorites": "Gunstelinge", + "HeaderFavoriteShows": "Gunsteling Vertonings", + "ValueSpecialEpisodeName": "Spesiaal - {0}", + "HeaderAlbumArtists": "Album Kunstenaars", + "Books": "Boeke", + "HeaderNextUp": "Volgende", + "Movies": "Rolprente", + "Shows": "Program", + "HeaderContinueWatching": "Hou Aan Kyk", + "HeaderFavoriteEpisodes": "Gunsteling Episodes", + "Photos": "Fotos", + "Playlists": "Speellysse", + "HeaderFavoriteArtists": "Gunsteling Kunstenaars", + "HeaderFavoriteAlbums": "Gunsteling Albums", + "Sync": "Sinkroniseer", + "HeaderFavoriteSongs": "Gunsteling Liedjies", + "Songs": "Liedjies", + "DeviceOnlineWithName": "{0} is verbind", + "DeviceOfflineWithName": "{0} het afgesluit", + "Collections": "Versamelings", + "Inherit": "Ontvang", + "HeaderLiveTV": "Live TV", + "Application": "Program", + "AppDeviceValues": "App: {0}, Toestel: {1}", + "VersionNumber": "Weergawe {0}", + "ValueHasBeenAddedToLibrary": "{0} is by jou media biblioteek bygevoeg", + "UserStoppedPlayingItemWithValues": "{0} het klaar {1} op {2} gespeel", + "UserStartedPlayingItemWithValues": "{0} is besig om {1} op {2} te speel", + "UserPolicyUpdatedWithName": "Gebruiker beleid is verander vir {0}", + "UserPasswordChangedWithName": "Gebruiker {0} se wagwoord is verander", + "UserOnlineFromDevice": "{0} is aanlyn van {1}", + "UserOfflineFromDevice": "{0} is ontkoppel van {1}", + "UserLockedOutWithName": "Gebruiker {0} is uitgesluit", + "UserDownloadingItemWithValues": "{0} is besig om {1} af te laai", + "UserDeletedWithName": "Gebruiker {0} is verwyder", + "UserCreatedWithName": "Gebruiker {0} is geskep", + "User": "Gebruiker", + "TvShows": "TV Programme", + "System": "Stelsel", + "SubtitlesDownloadedForItem": "Ondertitels afgelaai vir {0}", + "SubtitleDownloadFailureFromForItem": "Ondertitels het misluk om af te laai van {0} vir {1}", + "StartupEmbyServerIsLoading": "Jellyfin Bediener is besig om te laai. Probeer weer in 'n kort tyd.", + "ServerNameNeedsToBeRestarted": "{0} moet herbegin word", + "ScheduledTaskStartedWithName": "{0} het begin", + "ScheduledTaskFailedWithName": "{0} het misluk", + "ProviderValue": "Voorsiener: {0}", + "PluginUpdatedWithName": "{0} was opgedateer", + "PluginUninstalledWithName": "{0} was verwyder", + "PluginInstalledWithName": "{0} is geïnstalleer", + "Plugin": "Inprop module", + "NotificationOptionVideoPlaybackStopped": "Video terugspeel het gestop", + "NotificationOptionVideoPlayback": "Video terugspeel het begin", + "NotificationOptionUserLockedOut": "Gebruiker uitgeslyt", + "NotificationOptionTaskFailed": "Geskeduleerde taak het misluk", + "NotificationOptionServerRestartRequired": "Bediener herbegin nodig", + "NotificationOptionPluginUpdateInstalled": "Nuwe inprop module geïnstalleer", + "NotificationOptionPluginUninstalled": "Inprop module verwyder", + "NotificationOptionPluginInstalled": "Inprop module geïnstalleer", + "NotificationOptionPluginError": "Inprop module het misluk", + "NotificationOptionNewLibraryContent": "Nuwe inhoud bygevoeg", + "NotificationOptionInstallationFailed": "Installering het misluk", + "NotificationOptionCameraImageUploaded": "Kamera foto is opgelaai", + "NotificationOptionAudioPlaybackStopped": "Oudio terugspeel het gestop", + "NotificationOptionAudioPlayback": "Oudio terugspeel het begin", + "NotificationOptionApplicationUpdateInstalled": "Nuwe program weergawe geïnstalleer", + "NotificationOptionApplicationUpdateAvailable": "Nuwe program weergawe beskikbaar", + "NewVersionIsAvailable": "'n Nuwe Jellyfin Bedienaar weergawe kan afgelaai word.", + "NameSeasonUnknown": "Seisoen Onbekend", + "NameSeasonNumber": "Seisoen {0}", + "NameInstallFailed": "{0} installering het misluk", + "MusicVideos": "Musiek videos", + "Music": "Musiek", + "MixedContent": "Gemengde inhoud", + "MessageServerConfigurationUpdated": "Bediener konfigurasie is opgedateer", + "MessageNamedServerConfigurationUpdatedWithValue": "Bediener konfigurasie seksie {0} is opgedateer", + "MessageApplicationUpdatedTo": "Jellyfin Bediener is opgedateer na {0}", + "MessageApplicationUpdated": "Jellyfin Bediener is opgedateer", + "Latest": "Nuutste", + "LabelRunningTimeValue": "Lopende tyd: {0}", + "LabelIpAddressValue": "IP adres: {0}", + "ItemRemovedWithName": "{0} is uit versameling verwyder", + "ItemAddedWithName": "{0} is in die versameling", + "HomeVideos": "Tuis opnames", + "HeaderRecordingGroups": "Groep Opnames", + "HeaderCameraUploads": "Kamera Oplaai", + "Genres": "Genres", + "FailedLoginAttemptWithUserName": "Mislukte aansluiting van {0}", + "ChapterNameValue": "Hoofstuk", + "CameraImageUploadedFrom": "'n Nuwe kamera photo opgelaai van {0}", + "AuthenticationSucceededWithUserName": "{0} suksesvol geverifieer", + "Albums": "Albums" +}