aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Server/Extensions
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2026-02-14 12:07:30 +0100
committerGitHub <noreply@github.com>2026-02-14 12:07:30 +0100
commit29582ed461b693368ec56567c2e40cfa20ef4bf5 (patch)
tree04721b833e8e6108c2e13c4f0ea9f4dc7b2ae946 /Jellyfin.Server/Extensions
parentca6d499680f9fbb369844a11eb0e0213b66bb00b (diff)
parent3b6985986709473c69ba785460c702c6bbe3771d (diff)
Merge branch 'master' into issue15137
Diffstat (limited to 'Jellyfin.Server/Extensions')
-rw-r--r--Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs13
-rw-r--r--Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs51
2 files changed, 9 insertions, 55 deletions
diff --git a/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs
index a56baba33..9fd853cf2 100644
--- a/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiApplicationBuilderExtensions.cs
@@ -117,18 +117,5 @@ namespace Jellyfin.Server.Extensions
{
return appBuilder.UseMiddleware<RobotsRedirectionMiddleware>();
}
-
- /// <summary>
- /// Adds /emby and /mediabrowser route trimming to the application pipeline.
- /// </summary>
- /// <remarks>
- /// This must be injected before any path related middleware.
- /// </remarks>
- /// <param name="appBuilder">The application builder.</param>
- /// <returns>The updated application builder.</returns>
- public static IApplicationBuilder UsePathTrim(this IApplicationBuilder appBuilder)
- {
- return appBuilder.UseMiddleware<LegacyEmbyRouteRewriteMiddleware>();
- }
}
}
diff --git a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
index 08c1a5065..9df24fa0d 100644
--- a/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
+++ b/Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs
@@ -33,9 +33,11 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
+using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using AuthenticationSchemes = Jellyfin.Api.Constants.AuthenticationSchemes;
@@ -172,7 +174,7 @@ namespace Jellyfin.Server.Extensions
if (config.KnownProxies.Length == 0)
{
options.ForwardedHeaders = ForwardedHeaders.None;
- options.KnownNetworks.Clear();
+ options.KnownIPNetworks.Clear();
options.KnownProxies.Clear();
}
else
@@ -182,7 +184,7 @@ namespace Jellyfin.Server.Extensions
}
// Only set forward limit if we have some known proxies or some known networks.
- if (options.KnownProxies.Count != 0 || options.KnownNetworks.Count != 0)
+ if (options.KnownProxies.Count != 0 || options.KnownIPNetworks.Count != 0)
{
options.ForwardLimit = null;
}
@@ -253,13 +255,15 @@ namespace Jellyfin.Server.Extensions
c.AddSwaggerTypeMappings();
c.SchemaFilter<IgnoreEnumSchemaFilter>();
+ c.SchemaFilter<FlagsEnumSchemaFilter>();
c.OperationFilter<RetryOnTemporarilyUnavailableFilter>();
c.OperationFilter<SecurityRequirementsOperationFilter>();
c.OperationFilter<FileResponseFilter>();
c.OperationFilter<FileRequestFilter>();
c.OperationFilter<ParameterObsoleteFilter>();
c.DocumentFilter<AdditionalModelFilter>();
- });
+ })
+ .Replace(ServiceDescriptor.Transient<ISwaggerProvider, CachingOpenApiProvider>());
}
private static void AddPolicy(this AuthorizationOptions authorizationOptions, string policyName, IAuthorizationRequirement authorizationRequirement)
@@ -286,10 +290,7 @@ namespace Jellyfin.Server.Extensions
}
else if (NetworkUtils.TryParseToSubnet(allowedProxies[i], out var subnet))
{
- if (subnet is not null)
- {
- AddIPAddress(config, options, subnet.Prefix, subnet.PrefixLength);
- }
+ AddIPAddress(config, options, subnet.Address, subnet.Subnet.PrefixLength);
}
else if (NetworkUtils.TryParseHost(allowedProxies[i], out var addresses, config.EnableIPv4, config.EnableIPv6))
{
@@ -319,7 +320,7 @@ namespace Jellyfin.Server.Extensions
}
else
{
- options.KnownNetworks.Add(new Microsoft.AspNetCore.HttpOverrides.IPNetwork(addr, prefixLength));
+ options.KnownIPNetworks.Add(new System.Net.IPNetwork(addr, prefixLength));
}
}
@@ -339,25 +340,6 @@ namespace Jellyfin.Server.Extensions
}
});
- /*
- * Support BlurHash dictionary
- */
- options.MapType<Dictionary<ImageType, Dictionary<string, string>>>(() =>
- new OpenApiSchema
- {
- Type = "object",
- Properties = typeof(ImageType).GetEnumNames().ToDictionary(
- name => name,
- _ => new OpenApiSchema
- {
- Type = "object",
- AdditionalProperties = new OpenApiSchema
- {
- Type = "string"
- }
- })
- });
-
// Support dictionary with nullable string value.
options.MapType<Dictionary<string, string?>>(() =>
new OpenApiSchema
@@ -370,21 +352,6 @@ namespace Jellyfin.Server.Extensions
}
});
- // Manually describe Flags enum.
- options.MapType<TranscodeReason>(() =>
- new OpenApiSchema
- {
- Type = "array",
- Items = new OpenApiSchema
- {
- Reference = new OpenApiReference
- {
- Id = nameof(TranscodeReason),
- Type = ReferenceType.Schema,
- }
- }
- });
-
// Swashbuckle doesn't use JsonOptions to describe responses, so we need to manually describe it.
options.MapType<Version>(() => new OpenApiSchema
{