Skip to content

feat(relay): gate REQ/COUNT/NEG-OPEN for configured kinds behind NIP-42 AUTH#229

Open
Thunder-Blaze wants to merge 2 commits into
hoytech:masterfrom
Thunder-Blaze:feat/auth-on-read-for-kinds
Open

feat(relay): gate REQ/COUNT/NEG-OPEN for configured kinds behind NIP-42 AUTH#229
Thunder-Blaze wants to merge 2 commits into
hoytech:masterfrom
Thunder-Blaze:feat/auth-on-read-for-kinds

Conversation

@Thunder-Blaze

@Thunder-Blaze Thunder-Blaze commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Issue

Description

Resolves the above Issue by implementing read-side NIP-42 authentication to secure DMs. This addresses current structural limitations where AUTH is exclusively on the write-path and wildcard filters bypass validation.

  • By Default restrictedReadKinds = "" — zero behavior change for existing operators. Turn it on to lock down DM reads.

Key Changes:

  • New Configuration: Introduces relay.auth.restrictedReadKinds (an opt-in list of kinds requiring read AUTH) and restrictReadToInvolvedPubkey (ensures the authed pubkey is present in the filter's authors or #p tags).
  • Validation Gate: Intercepts REQ, COUNT, and NEG-OPEN requests. Unauthenticated or unauthorized queries for restricted kinds trigger an AUTH challenge and are safely closed.
  • Safe Defaults: Strictly opt-in (defaults to disabled).

Important

Security Enhancements: Closes the omitted-kinds bypass loophole (wildcard filters are automatically treated as restricted) and strictly "fails closed" (blocks requests) if read-auth is enabled but the auth service is unconfigured.

Config

  • Example of auth config in strfry.conf:

    auth {
        enabled = true
        serviceUrl = "wss://relay.example"
        restrictedReadKinds = "4,1059"
        restrictReadToInvolvedPubkey = true
    }
    

Testing

image image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auth on DMs Req

1 participant