0954876295
Implement B01-B06 with regression coverage and retained validation evidence. Preserve the production ingress preflight; F04 runtime verification remains open.
23 lines
796 B
C#
23 lines
796 B
C#
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace JobTrackerApi.Services;
|
|
|
|
public static class RateLimitPartitionKeys
|
|
{
|
|
public static string Account(HttpContext context, string policy)
|
|
{
|
|
var owner = LocalAuthIdentity.GetRequiredUserId(context.User);
|
|
// Separate namespaces prevent an anonymous address colliding with an account ID.
|
|
return owner is null
|
|
? $"{policy}:ip:{context.Connection.RemoteIpAddress?.ToString() ?? "unknown"}"
|
|
: $"{policy}:user:{owner}";
|
|
}
|
|
|
|
public static string PublicPdf(HttpContext context)
|
|
{
|
|
var client = context.Connection.RemoteIpAddress?.ToString() ?? "unknown";
|
|
var slug = context.Request.RouteValues["slug"]?.ToString() ?? "unknown";
|
|
return $"public-pdf:{client}:{slug}";
|
|
}
|
|
}
|