mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
test(auth): malformed headers still fill the bucket; document the challenge
Review on #838. The unchanged half had no test: send the cap's worth of `Authorization: Bearer x` and expect the next request to be 429, in single-user and multi-user mode. Both fail if the header-less skip is widened to malformed headers. docs/security-architecture.md gets a pipeline step for the header-less challenge (not counted, even during a lockout), and the Rate limit rows in CLAUDE.md and docs/architecture-invariants.md say so, so a later change cannot bring the counting back unnoticed. auth.ts uses challengeBasicAuth() at the two spots that still inlined it, with a blank comment line before the new paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
363de086fc
commit
ad08cb957d
6 files changed
+46
-11
No files matched your search
@@ -272,6 +272,21 @@ describe('Auth Security', () => {
|
||||
});
|
||||
expect(wrong.status).toBe(429);
|
||||
});
|
||||
|
||||
it('should still count malformed authorization headers and rate-limit them', async () => {
|
||||
// The other side of the line: a header that is present but not valid Basic
|
||||
// is a failed login, counted like a wrong password.
|
||||
for (let i = 0; i < AUTH_FAILURE_MAX; i++) {
|
||||
const res = await fetch(`${rateBaseUrl}/api/status`, {
|
||||
headers: { Authorization: 'Bearer x' },
|
||||
});
|
||||
expect(res.status, `request ${i + 1}`).toBe(401);
|
||||
}
|
||||
const res = await fetch(`${rateBaseUrl}/api/status`, {
|
||||
headers: { Authorization: 'Bearer x' },
|
||||
});
|
||||
expect(res.status).toBe(429);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Hook Event Endpoint', () => {
|
||||
|
||||
Reference in new issue
Block a user