Skip to content

feat: add admin backend foundation (login, session, health) - #641

Merged
cameri merged 6 commits into
cameri:mainfrom
Ferryx349:ADMIN-CONSOLE-1
Jul 4, 2026
Merged

feat: add admin backend foundation (login, session, health)#641
cameri merged 6 commits into
cameri:mainfrom
Ferryx349:ADMIN-CONSOLE-1

Conversation

@Ferryx349

@Ferryx349Ferryx349 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

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

Screenshot 2026-06-26 at 15 53 53

On local setup it is working well and ready for phase 2.

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.
  • My code follows the code style of this project.

@changeset-bot

changeset-botBot commented Jun 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 61c30c8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
nostreamMinor

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

@Ferryx349
Ferryx349 marked this pull request as draft June 7, 2026 08:18
Comment threadsrc/routes/admin/index.ts Fixed
Comment threadsrc/routes/admin/index.ts Fixed
@coveralls

coveralls commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 67.243% (+0.5%) from 66.747% — Ferryx349:ADMIN-CONSOLE-1 into cameri:main

@Ferryx349
Ferryx349force-pushed the ADMIN-CONSOLE-1 branch 2 times, most recently from 014b0c8 to 92516e3CompareJune 12, 2026 08:19
Comment threadsrc/routes/admin/index.ts Fixed
Comment threadsrc/routes/admin/index.ts Fixed
@Ferryx349
Ferryx349 marked this pull request as ready for review June 12, 2026 08:21
@Ferryx349
Ferryx349 requested review from cameri and CopilotJune 16, 2026 04:09

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /admin router with /login, /session, and /health endpoints.
  • 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
FileDescription
test/unit/utils/admin-session.spec.tsUnit tests for session token creation/validation and request extraction.
test/unit/utils/admin-rate-limit.spec.tsUnit tests for admin/login rate-limiting behavior.
test/unit/routes/admin.spec.tsRouter-level tests for disabled-by-default, login, and protected endpoints.
src/utils/admin-session.tsSigned session token generation/validation + extraction from headers/cookies.
src/utils/admin-rate-limit.tsAdmin/login rate-limit helper using configured limits + IP whitelist.
src/utils/admin-password.tsPassword hashing/verification helpers (scrypt + timing-safe compare).
src/utils/admin-health.tsAdmin health snapshot collection (DB + Redis ping).
src/schemas/admin-login-schema.tsZod schema for admin login request body.
src/routes/index.tsMount /admin router into the main routing table.
src/routes/admin/index.tsAdmin router implementation: enabled-gate, login/session/health wiring.
src/handlers/request-handlers/admin-rate-limit-middleware.tsExpress middlewares for admin and login rate limiting.
src/factories/controllers/post-admin-login-controller-factory.tsFactory wiring for login controller.
src/factories/controllers/get-admin-session-controller-factory.tsFactory wiring for session controller.
src/factories/controllers/get-admin-health-controller-factory.tsFactory wiring for health controller.
src/factories/admin-auth-provider-factory.tsFactory for selecting/admin auth provider (currently password-based).
src/controllers/admin/post-login-controller.tsController delegating login to auth provider.
src/controllers/admin/get-session-controller.tsController returning session status/expiry.
src/controllers/admin/get-health-controller.tsController returning admin health snapshot.
src/admin/password-admin-auth-provider.tsPassword auth provider: login + cookie issuance + request auth checks.
src/@types/settings.tsAdd admin settings and limits.admin typing.
src/@types/admin.tsDefine IAdminAuthProvider interface.
resources/default-settings.yamlAdd default admin settings and admin rate-limit defaults.
.changeset/admin-console-phase-1.mdChangeset entry for the new admin API foundation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadsrc/admin/password-admin-auth-provider.ts Outdated
Comment threadsrc/admin/password-admin-auth-provider.ts
Comment threadsrc/admin/password-admin-auth-provider.ts
Comment threadsrc/controllers/admin/get-session-controller.ts
Comment threadsrc/routes/admin/index.ts Outdated
Comment threadsrc/handlers/request-handlers/admin-rate-limit-middleware.ts
@Ferryx349
Ferryx349 marked this pull request as draft June 16, 2026 18:03
@Ferryx349

Ferryx349 commented Jun 18, 2026

Copy link
Copy Markdown
CollaboratorAuthor

I have squashed commits and force pushed to fix lint failures in CI getting due to wrong commit structure.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.

Comment threadsrc/utils/admin-rate-limit.ts
Comment threadsrc/routes/admin/index.ts Outdated
Comment threadsrc/admin/password-admin-auth-provider.ts
@Ferryx349
Ferryx349 marked this pull request as ready for review June 18, 2026 08:20
@Ferryx349

Copy link
Copy Markdown
CollaboratorAuthor

@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>
Comment threadsrc/routes/admin/index.ts
Comment threadsrc/routes/admin/index.ts
@cameri
cameri merged commit 837540b into cameri:mainJul 4, 2026
16 of 18 checks passed
Ferryx349 added a commit to Ferryx349/nostream that referenced this pull request Jul 4, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
@Ferryx349
Ferryx349 deleted the ADMIN-CONSOLE-1 branch July 4, 2026 14:54
Sign up for freeto 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.

5 participants

@Ferryx349@coveralls@cameri@github-advanced-security