fix(jellyfin): merge modern internal auth headers from PR 25

This commit is contained in:
joshpatra committed 2026-09-27 17:23:22 -04:00
commit 78e305ab1f
6 files changed
+9 -7

No files matched your search

@@ -42,7 +42,8 @@ public sealed class BackendLibraryIndexingTests
Assert.Equal("USABC1234567", track.Isrc);
Assert.Equal("16ba7915-2acf-42b2-8c87-ed67090dca91", track.MusicBrainzRecordingId);
Assert.Equal("jellyfin-cover:song-1:cover-v1", track.CoverArtReference);
Assert.Equal("ephemeral-key", handler.LastRequest!.Headers.GetValues("X-Emby-Token").Single());
Assert.Contains("Token=\"ephemeral-key\"", handler.LastRequest!.Headers.GetValues("Authorization").Single());
Assert.False(handler.LastRequest.Headers.Contains("X-Emby-Token"));
Assert.DoesNotContain("Audio", handler.LastRequest.RequestUri!.AbsolutePath, StringComparison.OrdinalIgnoreCase);
Assert.Contains(
"IncludeItemTypes=Audio",
+1 -1
View File
@@ -245,7 +245,7 @@ public sealed class AdminAuthController : ControllerBase
{
using var request = new HttpRequestMessage(HttpMethod.Get,
$"{_jellyfinSettings.Url!.TrimEnd('/')}/Users/{Uri.EscapeDataString(userId)}/Images/Primary?width=96&quality=90");
request.Headers.TryAddWithoutValidation("X-Emby-Token", session.JellyfinAccessToken);
request.Headers.TryAddWithoutValidation("Authorization", AuthHeaderHelper.CreateAuthHeader(session.JellyfinAccessToken, "AllstarrAdmin", "WebUI", "allstarr-admin-webui", AppVersion.Version));
using var response = await _httpClient.SendAsync(request, token);
var contentType = response.Content.Headers.ContentType?.MediaType;
if (!response.IsSuccessStatusCode ||
@@ -138,8 +138,7 @@ public class JellyfinAdminController : ControllerBase
var request = new HttpRequestMessage(method, url);
var authHeader =
$"MediaBrowser Client=\"AllstarrAdmin\", Device=\"WebUI\", DeviceId=\"allstarr-admin-webui\", Version=\"{AppVersion.Version}\", Token=\"{session.JellyfinAccessToken}\"";
request.Headers.TryAddWithoutValidation("X-Emby-Authorization", authHeader);
request.Headers.TryAddWithoutValidation("X-Emby-Token", session.JellyfinAccessToken);
request.Headers.TryAddWithoutValidation("Authorization", authHeader);
return request;
}
@@ -7,6 +7,7 @@ using allstarr.Core.Playlists.Targets;
using allstarr.Core.Protocols;
using allstarr.Core.Storage;
using allstarr.Models.Settings;
using allstarr.Services.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@@ -59,7 +60,7 @@ public sealed class JellyfinLibraryRefresher : IBackendLibraryRefresher
throw new InvalidOperationException("Jellyfin library refresh is not configured.");
using var message = new HttpRequestMessage(HttpMethod.Post,
new Uri(new Uri(_settings.Url.TrimEnd('/') + "/"), "Library/Refresh"));
message.Headers.TryAddWithoutValidation("X-Emby-Token", _settings.ApiKey);
message.Headers.TryAddWithoutValidation("Authorization", AuthHeaderHelper.CreateAuthHeader(_settings.ApiKey, "Allstarr", "Server", "allstarr-server", AppVersion.Version));
using var response = await _http.SendAsync(message, cancellationToken);
response.EnsureSuccessStatusCode();
return new(true);
@@ -8,6 +8,7 @@ using allstarr.Core.Playlists.Targets;
using allstarr.Core.Protocols;
using allstarr.Core.Storage;
using allstarr.Models.Settings;
using allstarr.Services.Common;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
@@ -75,7 +76,7 @@ public sealed class JellyfinLibraryCatalogScanner : JsonLibraryCatalogScanner, I
var uri = new Uri(new Uri(_settings.Url.TrimEnd('/') + "/"),
$"Items?Recursive=true&IncludeItemTypes=Audio&StartIndex={offset}&Limit={request.PageSize}&Fields=Path,ProviderIds,DateModified,DateCreated,Album,AlbumArtist,Artists,RunTimeTicks,ImageTags");
using var message = new HttpRequestMessage(HttpMethod.Get, uri);
message.Headers.TryAddWithoutValidation("X-Emby-Token", _settings.ApiKey);
message.Headers.TryAddWithoutValidation("Authorization", AuthHeaderHelper.CreateAuthHeader(_settings.ApiKey, "Allstarr", "Server", "allstarr-server", AppVersion.Version));
using var response = await _http.SendAsync(message, cancellationToken);
response.EnsureSuccessStatusCode();
using var document = JsonDocument.Parse(await response.Content.ReadAsByteArrayAsync(cancellationToken));
@@ -151,7 +151,7 @@ public class AdminHelperService
public HttpRequestMessage CreateJellyfinRequest(HttpMethod method, string url)
{
var request = new HttpRequestMessage(method, url);
request.Headers.Add("X-Emby-Authorization", GetJellyfinAuthHeader());
request.Headers.Add("Authorization", GetJellyfinAuthHeader());
return request;
}