Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+4
-2
@@ -1,7 +1,7 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { cache } from "~/utils/cache.server";
|
||||
import { getClientIPAddress } from "~/utils/server/IpUtils";
|
||||
import { getTrustedClientIp } from "~/utils/server/IpUtils";
|
||||
|
||||
type AuthRateLimitOptions = {
|
||||
request: Request;
|
||||
@@ -16,7 +16,9 @@ type AuthRateLimitResult =
|
||||
| { allowed: false; retryAfterSeconds: number };
|
||||
|
||||
export function getAuthRateLimitKey({ request, action, identifier }: Omit<AuthRateLimitOptions, "limit" | "windowMs">) {
|
||||
const ipAddress = getClientIPAddress(request.headers)?.toString() ?? "unknown";
|
||||
// Trusted proxy-set header only; leftmost X-Forwarded-For / X-Client-IP are
|
||||
// client-spoofable and would let an attacker reset this per-IP auth throttle.
|
||||
const ipAddress = getTrustedClientIp(request) || "unknown";
|
||||
const normalizedIdentifier = identifier?.trim().toLowerCase() ?? "";
|
||||
const digest = createHash("sha256").update(`${action}:${ipAddress}:${normalizedIdentifier}`).digest("hex");
|
||||
return `auth-rate-limit:${action}:${digest}`;
|
||||
|
||||
Reference in new issue
Block a user