PR Gates / decisions lifecycle (pull_request) Failing after 12s
PR Gates / CI image pin matches docker/ci (pull_request) Successful in 21s
PR Gates / Docs update reminder (pull_request) Successful in 21s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 7m24s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 22s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 19s
Build ErsatzTV Image / Functional E2E (curl contracts) (pull_request) Successful in 5m25s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 15m51s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
#421 — a token containing a double-quote/ampersand could break out of the quoted M3U `url-tvg="..."`/`tvg-logo="..."` attributes or split the query. Percent-encode (`Uri.EscapeDataString`) at every site the token is interpolated into an M3U/HLS/XMLTV URL: `ChannelPlaylist.ToM3U`, `IptvController.AccessTokenQuery`, `FFmpegLibraryProcessService.WrapSegmenter`, and the XMLTV twin `GetChannelGuideHandler` (percent-encode then XML-escape). No-op for a normal base64url JWT, so the M3U/XMLTV goldens are byte-identical. #559 — (1) Serilog logged the full `?access_token=<jwt>` query on any 5xx/Error `/iptv` request. `IncludeQueryInRequestPath = false` + a new `RequestLogScrubber` enriching `RequestPathScrubbed` (masks the token to `***`, keeps other params) that the message template now references. (2) Token-bearing dynamic manifests (`channels.m3u`, `xmltv.xml`, the `.m3u8` HLS manifests, and their token-bearing 302 Locations) now return `Cache-Control: private, no-store`. Independent cold review (2 rounds) clean. Live-E2E verified: no-store header on m3u/xmltv/m3u8, token percent-encoded in url-tvg, and the request log rendering `access_token=***` with the raw token absent. Decision record `security.iptv-access-token-transport` added; resolves the deferred-hardening note under `security.iptv-browser-token`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using ErsatzTV.Application.Channels;
|
|
using ErsatzTV.Controllers;
|
|
using ErsatzTV.Core.Interfaces.FFmpeg;
|
|
using ErsatzTV.Core.Interfaces.Streaming;
|
|
using ErsatzTV.Core.Iptv;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using NSubstitute;
|
|
using NUnit.Framework;
|
|
using Shouldly;
|
|
|
|
namespace ErsatzTV.Tests.Controllers;
|
|
|
|
// #559: dynamic /iptv manifests embed the caller's access_token in their body/URLs, so the response must
|
|
// be marked no-store to keep a browser or intermediary from caching (and later replaying) the token.
|
|
[TestFixture]
|
|
public class IptvControllerCacheHeaderTests
|
|
{
|
|
[Test]
|
|
public async Task GetChannelPlaylist_sets_no_store()
|
|
{
|
|
var mediator = Substitute.For<IMediator>();
|
|
mediator.Send(Arg.Any<GetChannelPlaylist>(), Arg.Any<CancellationToken>())
|
|
.Returns(new ChannelPlaylist("https", "tv.example.com", string.Empty, [], "VLC/3.0", accessToken: null));
|
|
|
|
var controller = new IptvController(
|
|
mediator,
|
|
Substitute.For<IGraphicsEngine>(),
|
|
Substitute.For<ILogger<IptvController>>(),
|
|
Substitute.For<IFFmpegSegmenterService>(),
|
|
Substitute.For<IDirectStreamSessionTracker>())
|
|
{
|
|
ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext() }
|
|
};
|
|
|
|
await controller.GetChannelPlaylist();
|
|
|
|
controller.Response.Headers.CacheControl.ToString().ShouldBe("private, no-store");
|
|
}
|
|
}
|