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
+14
-3
@@ -16,7 +16,7 @@ describe("auth rate limiting", () => {
|
||||
|
||||
it("builds stable keys from action, client ip, and normalized identifier", () => {
|
||||
const request = new Request("https://example.test/login", {
|
||||
headers: { "x-forwarded-for": "203.0.113.10, 198.51.100.5" },
|
||||
headers: { "cf-connecting-ip": "203.0.113.10" },
|
||||
});
|
||||
|
||||
expect(getAuthRateLimitKey({ request, action: "login", identifier: " Ada@Example.COM " })).toBe(
|
||||
@@ -27,9 +27,20 @@ describe("auth rate limiting", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("does not key on a spoofable X-Forwarded-For / X-Client-IP", () => {
|
||||
// Both spoofable headers must be ignored, so a forged value cannot move the
|
||||
// request into a fresh rate-limit bucket. Both requests collapse to the same
|
||||
// (untrusted -> "unknown") key.
|
||||
const forged = new Request("https://example.test/login", { headers: { "x-forwarded-for": "9.9.9.9", "x-client-ip": "8.8.8.8" } });
|
||||
const bare = new Request("https://example.test/login", {});
|
||||
expect(getAuthRateLimitKey({ request: forged, action: "login", identifier: "ada@example.com" })).toBe(
|
||||
getAuthRateLimitKey({ request: bare, action: "login", identifier: "ada@example.com" })
|
||||
);
|
||||
});
|
||||
|
||||
it("allows requests up to the limit and returns retry timing after the limit", () => {
|
||||
const request = new Request("https://example.test/login", {
|
||||
headers: { "x-client-ip": "203.0.113.10" },
|
||||
headers: { "cf-connecting-ip": "203.0.113.10" },
|
||||
});
|
||||
const options = { request, action: "login" as const, identifier: "ada@example.com", limit: 2, windowMs: 30_000 };
|
||||
|
||||
@@ -40,7 +51,7 @@ describe("auth rate limiting", () => {
|
||||
|
||||
it("starts a new window after the cached counter expires", () => {
|
||||
const request = new Request("https://example.test/mfa", {
|
||||
headers: { "x-client-ip": "203.0.113.10" },
|
||||
headers: { "cf-connecting-ip": "203.0.113.10" },
|
||||
});
|
||||
const options = { request, action: "mfa" as const, identifier: "ada@example.com", limit: 1, windowMs: 10_000 };
|
||||
|
||||
|
||||
Reference in new issue
Block a user