mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-28 04:51:54 +00:00
Merge remote-tracking branch 'upstream/master' into api-doc-css
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Jellyfin.Server.Middleware;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
@@ -48,5 +49,55 @@ namespace Jellyfin.Server.Extensions
|
||||
c.InjectStylesheet($"/{baseUrl}api-docs/redoc/custom.css");
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds IP based access validation to the application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="appBuilder">The application builder.</param>
|
||||
/// <returns>The updated application builder.</returns>
|
||||
public static IApplicationBuilder UseIpBasedAccessValidation(this IApplicationBuilder appBuilder)
|
||||
{
|
||||
return appBuilder.UseMiddleware<IpBasedAccessValidationMiddleware>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds LAN based access filtering to the application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="appBuilder">The application builder.</param>
|
||||
/// <returns>The updated application builder.</returns>
|
||||
public static IApplicationBuilder UseLanFiltering(this IApplicationBuilder appBuilder)
|
||||
{
|
||||
return appBuilder.UseMiddleware<LanFilteringMiddleware>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds base url redirection to the application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="appBuilder">The application builder.</param>
|
||||
/// <returns>The updated application builder.</returns>
|
||||
public static IApplicationBuilder UseBaseUrlRedirection(this IApplicationBuilder appBuilder)
|
||||
{
|
||||
return appBuilder.UseMiddleware<BaseUrlRedirectionMiddleware>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a custom message during server startup to the application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="appBuilder">The application builder.</param>
|
||||
/// <returns>The updated application builder.</returns>
|
||||
public static IApplicationBuilder UseServerStartupMessage(this IApplicationBuilder appBuilder)
|
||||
{
|
||||
return appBuilder.UseMiddleware<ServerStartupMessageMiddleware>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a WebSocket request handler to the application pipeline.
|
||||
/// </summary>
|
||||
/// <param name="appBuilder">The application builder.</param>
|
||||
/// <returns>The updated application builder.</returns>
|
||||
public static IApplicationBuilder UseWebSocketHandler(this IApplicationBuilder appBuilder)
|
||||
{
|
||||
return appBuilder.UseMiddleware<WebSocketHandlerMiddleware>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Api.Controllers;
|
||||
using Jellyfin.Server.Formatters;
|
||||
using Jellyfin.Server.Models;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Json;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
@@ -135,10 +136,11 @@ namespace Jellyfin.Server.Extensions
|
||||
/// </summary>
|
||||
/// <param name="serviceCollection">The service collection.</param>
|
||||
/// <param name="baseUrl">The base url for the API.</param>
|
||||
/// <param name="pluginAssemblies">An IEnumberable containing all plugin assemblies with API controllers.</param>
|
||||
/// <returns>The MVC builder.</returns>
|
||||
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl)
|
||||
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IEnumerable<Assembly> pluginAssemblies)
|
||||
{
|
||||
return serviceCollection
|
||||
IMvcBuilder mvcBuilder = serviceCollection
|
||||
.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(ServerCorsPolicy.DefaultPolicyName, ServerCorsPolicy.DefaultPolicy);
|
||||
@@ -168,6 +170,9 @@ namespace Jellyfin.Server.Extensions
|
||||
// From JsonDefaults
|
||||
options.JsonSerializerOptions.ReadCommentHandling = jsonOptions.ReadCommentHandling;
|
||||
options.JsonSerializerOptions.WriteIndented = jsonOptions.WriteIndented;
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = jsonOptions.DefaultIgnoreCondition;
|
||||
options.JsonSerializerOptions.NumberHandling = jsonOptions.NumberHandling;
|
||||
|
||||
options.JsonSerializerOptions.Converters.Clear();
|
||||
foreach (var converter in jsonOptions.Converters)
|
||||
{
|
||||
@@ -176,8 +181,14 @@ namespace Jellyfin.Server.Extensions
|
||||
|
||||
// From JsonDefaults.PascalCase
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
|
||||
})
|
||||
.AddControllersAsServices();
|
||||
});
|
||||
|
||||
foreach (Assembly pluginAssembly in pluginAssemblies)
|
||||
{
|
||||
mvcBuilder.AddApplicationPart(pluginAssembly);
|
||||
}
|
||||
|
||||
return mvcBuilder.AddControllersAsServices();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -194,7 +205,7 @@ namespace Jellyfin.Server.Extensions
|
||||
{
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
In = ParameterLocation.Header,
|
||||
Name = "X-Emby-Token",
|
||||
Name = "X-Emby-Authorization",
|
||||
Description = "API key header parameter"
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user