jirorian/jirorian/auth.py
randogoth a56195620a Initial scaffold for jirorian
uv project with FastAPI + boto3 + pynostr, wired to uv2nix flake.
Stub modules for NIP-98 auth, NIP-96 upload endpoint, R2 presigned
URLs, Nostr relay subscription, and SQLite whitelist/rate-limit store.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 17:28:06 +03:00

12 lines
538 B
Python

# NIP-98 HTTP Auth verification
# Verifies kind:27235 Nostr events used as Bearer tokens.
# Rejects events older than MAX_AGE_SECONDS to prevent replay attacks.
MAX_AGE_SECONDS = 60
async def verify_nip98(authorization: str, expected_url: str, expected_method: str) -> str:
# TODO: base64-decode the event, verify secp256k1 signature via pynostr,
# check created_at freshness, url and method tags match request.
# Returns the verified pubkey (hex) on success, raises HTTPException on failure.
raise NotImplementedError