mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-nostr.git
synced 2026-05-24 14:25:36 +00:00
feat(auth): require signed NIP-42 event for Nostr login
Closes a security flaw where the server trusted any pubkey the client sent. The frontend now signs a per-session, time-bound challenge (kind-22242 event) that the backend verifies with swentel/nostr-php before establishing the session. - NostrAuth: issueChallenge() + loginWithSignedEvent() with full schnorr/id verification, TTL window, and idempotent re-entry for concurrent Livewire listeners. - auth-button: mounts a fresh challenge, exposes it via data-attribute + requestNostrChallenge() fallback, renders a full-viewport AAA-style loading overlay while the wallet signs. - NostrSessionGuard: override logout() to drop the cookie-jar dep so programmatic logout works in any context.
This commit is contained in:
@@ -53,14 +53,14 @@ test('voting actions are rate limited after 10 attempts', function () {
|
||||
});
|
||||
|
||||
test('nostr login is rate limited after 10 attempts', function () {
|
||||
$pleb = EinundzwanzigPleb::factory()->create();
|
||||
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
RateLimiter::attempt('nostr-login:127.0.0.1', 10, function () {});
|
||||
}
|
||||
|
||||
// Rate limit is checked before signature verification, so an empty
|
||||
// payload is enough to trigger the 429.
|
||||
Livewire::test('association.project-support.index')
|
||||
->call('handleNostrLogin', $pleb->pubkey)
|
||||
->call('handleNostrLogin', [])
|
||||
->assertStatus(429);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user