feat(admin): accept NIP-98 auth on admin API routes - #730
Draft
Anshumancanrock wants to merge 1 commit into
Draft
Conversation
🦋 Changeset detectedLatest commit: 5ca12e7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| router.get('/metrics', adminRateLimitMiddleware, adminAuthMiddleware, withAdminController(createGetAdminMetricsController)) | ||
| router.get('/settings', adminRateLimitMiddleware, adminAuthMiddleware, withAdminController(createGetAdminSettingsController)) | ||
| router.get( | ||
| '/session', |
| router.get( | ||
| '/session', | ||
| adminRateLimitMiddleware, | ||
| adminAuthMiddleware, |
| withAdminController(createGetAdminSessionController), | ||
| ) | ||
| router.get( | ||
| '/health', |
| router.get( | ||
| '/health', | ||
| adminRateLimitMiddleware, | ||
| adminAuthMiddleware, |
| router.get( | ||
| '/metrics', | ||
| adminRateLimitMiddleware, | ||
| adminAuthMiddleware, |
| router.get( | ||
| '/settings', | ||
| adminRateLimitMiddleware, | ||
| adminAuthMiddleware, |
| router.patch( | ||
| '/settings', | ||
| adminRateLimitMiddleware, | ||
| adminAuthGateMiddleware, |
| adminRateLimitMiddleware, | ||
| adminAuthGateMiddleware, | ||
| adminJsonBodyMiddleware, | ||
| adminAuthMiddleware, |
| router.post( | ||
| '/settings/validate', | ||
| adminRateLimitMiddleware, | ||
| adminAuthGateMiddleware, |
| router.post( | ||
| '/settings/restore', | ||
| adminRateLimitMiddleware, | ||
| adminAuthGateMiddleware, |
Collaborator
Collaborator
Author
|
I think CodeQL doesn’t recognize our Redis adminRateLimitMiddleware (it only models express-rate-limit etc). These routes still run that limiter before auth, same as the rest of this file. |
Collaborator
|
@Anshumancanrock totally agree, its a codeql false positive, it was happening same with me too, had tried a fix in #692. |
Anshumancanrock
marked this pull request as draft
August 13, 2026 14:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Protected admin API routes now accept
Authorization: Nostron top of the existing session cookie.Off by default. Set
admin.nip98.enabledand put hex pubkeys inadmin.nip98.allowedPubkeys. Empty allowlist means nobody gets in that way.For PATCH/POST we check the header (sig + allowlist) before parsing JSON, so a junk
Nostrtoken never hits the 1mb body parser. After the body is read we check the payload hash and store the event id in Redis withSET NX(TTL =maxSkewSeconds). Same event twice, or Redis down → 401.GETs don't parse a body. Same session-or-NIP-98 check, including the one-time event id.
Clients still sign
uagainstinfo.relay_url(not the requestHost). Password login / dashboard / cookie session are unchanged;/loginstays 100kb.Related Issue
Follows #722 (verifier), #725 (absolute URL), #726 (Redis NX).
Motivation and Context
#722 only verifies a header. This is the part that actually lets you call the admin API with a signed event instead of sharing the password.