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.
This commit is contained in:
@@ -34,10 +34,6 @@ public sealed class TicketValidator : IDisposable
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Validates the stream ticket and returns the authorized object-key prefix,
|
|
||||||
/// or <see langword="null"/> if the ticket is missing, invalid, or carries no prefix.
|
|
||||||
/// </summary>
|
|
||||||
public async Task<string?> ValidateTicketAsync(string? token)
|
public async Task<string?> ValidateTicketAsync(string? token)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(token))
|
if (string.IsNullOrWhiteSpace(token))
|
||||||
@@ -47,11 +43,8 @@ public sealed class TicketValidator : IDisposable
|
|||||||
if (!result.IsValid)
|
if (!result.IsValid)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return result.Claims.TryGetValue("prefix", out var claim)
|
var prefix = result.ClaimsIdentity?.FindFirst("prefix")?.Value;
|
||||||
&& claim is string prefix
|
return string.IsNullOrEmpty(prefix) ? null : prefix;
|
||||||
&& !string.IsNullOrEmpty(prefix)
|
|
||||||
? prefix
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() => _rsa.Dispose();
|
public void Dispose() => _rsa.Dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user