From f6bab8c0d8c7058ea9e16cc0310201f9054712cd Mon Sep 17 00:00:00 2001 From: XShine555 Date: Sun, 5 Jul 2026 21:59:55 +0200 Subject: [PATCH] refactor(gateway): simplify prefix extraction in TicketValidator Read the prefix claim via ClaimsIdentity.FindFirst instead of a three-part ternary over the claims dictionary, and drop the XML summary. --- .../Authentication/TicketValidator.cs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/backend/Musify.StreamingGateway/Authentication/TicketValidator.cs b/backend/Musify.StreamingGateway/Authentication/TicketValidator.cs index 4bd012c..3ea8ea8 100644 --- a/backend/Musify.StreamingGateway/Authentication/TicketValidator.cs +++ b/backend/Musify.StreamingGateway/Authentication/TicketValidator.cs @@ -34,10 +34,6 @@ public sealed class TicketValidator : IDisposable }; } - /// - /// Validates the stream ticket and returns the authorized object-key prefix, - /// or if the ticket is missing, invalid, or carries no prefix. - /// public async Task ValidateTicketAsync(string? token) { if (string.IsNullOrWhiteSpace(token)) @@ -47,11 +43,8 @@ public sealed class TicketValidator : IDisposable if (!result.IsValid) return null; - return result.Claims.TryGetValue("prefix", out var claim) - && claim is string prefix - && !string.IsNullOrEmpty(prefix) - ? prefix - : null; + var prefix = result.ClaimsIdentity?.FindFirst("prefix")?.Value; + return string.IsNullOrEmpty(prefix) ? null : prefix; } public void Dispose() => _rsa.Dispose();