feat: add admin backend foundation (login, session, health) - #641
Conversation
🦋 Changeset detectedLatest commit: 61c30c8 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 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
014b0c8 to
92516e3CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
This PR lays the groundwork for an (optionally enabled) admin backend by introducing an /admin API surface with password-based login, signed sessions, and a protected health endpoint, along with supporting settings and unit tests.
Changes:
- Add a disabled-by-default
/adminrouter with/login,/session, and/healthendpoints. - Introduce password auth provider + signed session token utilities, plus admin-specific rate limiting.
- Extend settings/types and defaults to configure admin enablement, session TTL, and admin rate limits; add unit tests and changeset.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/unit/utils/admin-session.spec.ts | Unit tests for session token creation/validation and request extraction. |
| test/unit/utils/admin-rate-limit.spec.ts | Unit tests for admin/login rate-limiting behavior. |
| test/unit/routes/admin.spec.ts | Router-level tests for disabled-by-default, login, and protected endpoints. |
| src/utils/admin-session.ts | Signed session token generation/validation + extraction from headers/cookies. |
| src/utils/admin-rate-limit.ts | Admin/login rate-limit helper using configured limits + IP whitelist. |
| src/utils/admin-password.ts | Password hashing/verification helpers (scrypt + timing-safe compare). |
| src/utils/admin-health.ts | Admin health snapshot collection (DB + Redis ping). |
| src/schemas/admin-login-schema.ts | Zod schema for admin login request body. |
| src/routes/index.ts | Mount /admin router into the main routing table. |
| src/routes/admin/index.ts | Admin router implementation: enabled-gate, login/session/health wiring. |
| src/handlers/request-handlers/admin-rate-limit-middleware.ts | Express middlewares for admin and login rate limiting. |
| src/factories/controllers/post-admin-login-controller-factory.ts | Factory wiring for login controller. |
| src/factories/controllers/get-admin-session-controller-factory.ts | Factory wiring for session controller. |
| src/factories/controllers/get-admin-health-controller-factory.ts | Factory wiring for health controller. |
| src/factories/admin-auth-provider-factory.ts | Factory for selecting/admin auth provider (currently password-based). |
| src/controllers/admin/post-login-controller.ts | Controller delegating login to auth provider. |
| src/controllers/admin/get-session-controller.ts | Controller returning session status/expiry. |
| src/controllers/admin/get-health-controller.ts | Controller returning admin health snapshot. |
| src/admin/password-admin-auth-provider.ts | Password auth provider: login + cookie issuance + request auth checks. |
| src/@types/settings.ts | Add admin settings and limits.admin typing. |
| src/@types/admin.ts | Define IAdminAuthProvider interface. |
| resources/default-settings.yaml | Add default admin settings and admin rate-limit defaults. |
| .changeset/admin-console-phase-1.md | Changeset entry for the new admin API foundation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have squashed commits and force pushed to fix lint failures in CI getting due to wrong commit structure. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Ferryx349
commented
Jun 25, 2026
@cameri can u PTAL so we can proceed to our next phase, after merging this one.. |
Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
- Move admin enabled/auth checks into request-handlers middleware - Reuse admin auth provider instance per process - Deduplicate admin rate-limit middleware via scope factory - Return JSON errors from admin controller wrapper - Drop duplicated sessionTtlSeconds default from settings yaml Signed-off-by: ABHAY PANDEY <pandeyabhay967@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Cursor <cursoragent@cursor.com>
Description
This is the groundwork for admin console backend with a disabled-by-default admin API. Currently with password login(will replace it with NIP-98 later). API also includes session management, and a protected health endpoint.
Related Issue
#631
Screenshots
On local setup it is working well and ready for phase 2.
Types of changes
Checklist: