From 99cd01f73b938e9dcba3050c60ad3b7d807fe334 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:16:46 -0600 Subject: [PATCH] update iptv routing (#1631) --- CHANGELOG.md | 1 + ErsatzTV/Startup.cs | 39 +++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 698c90f68..7dc8d42a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Search index updates should now complete at the same time as library scans - Do not unnecessarily update the search index during media server library scans - Use different library for reading song metadata that supports multiple tag entries +- Update `/iptv` routing to make UI completely inaccessible from that path prefix ## [0.8.5-beta] - 2024-01-30 ### Added diff --git a/ErsatzTV/Startup.cs b/ErsatzTV/Startup.cs index 31b17ea93..a0090a6ba 100644 --- a/ErsatzTV/Startup.cs +++ b/ErsatzTV/Startup.cs @@ -531,23 +531,38 @@ public class Startup // ServeUnknownFileTypes = true }); - app.UseRouting(); + app.MapWhen( + ctx => !ctx.Request.Path.StartsWithSegments("/iptv"), + blazor => + { + blazor.UseRouting(); - if (OidcHelper.IsEnabled) - { - app.UseAuthentication(); - app.UseAuthorization(); - } + if (OidcHelper.IsEnabled) + { + blazor.UseAuthentication(); +#pragma warning disable ASP0001 + blazor.UseAuthorization(); +#pragma warning restore ASP0001 + } + + blazor.UseEndpoints( + endpoints => + { + endpoints.MapControllers(); + endpoints.MapBlazorHub(); + endpoints.MapFallbackToPage("/_Host"); + }); + }); - app.UseEndpoints( - endpoints => + app.MapWhen( + ctx => ctx.Request.Path.StartsWithSegments("/iptv"), + iptv => { - endpoints.MapControllers(); - endpoints.MapBlazorHub(); - endpoints.MapFallbackToPage("/_Host"); + iptv.UseRouting(); + iptv.UseEndpoints(endpoints => endpoints.MapControllers()); }); } - + private static void CustomServices(IServiceCollection services) { services.AddSingleton();