Stage 2: integrate administrative login and protect dashboard
This commit is contained in:
@@ -1,11 +1,22 @@
|
||||
# Administrative authentication foundation
|
||||
|
||||
## Stage 1 scope
|
||||
## Integrated administrative sign-in
|
||||
|
||||
This foundation is independent of NextAuth, Prisma, CRM, the existing `/admin`
|
||||
page restriction, and draft deletion. It provides shared-credential login,
|
||||
logout, and session-status API handlers only. It is not wired into `/admin` or
|
||||
any storage API in this stage.
|
||||
Administrators sign in at `/admin/login` using the shared credential configured
|
||||
as `ADMIN_AUTH_SECRET`. The page submits the credential directly to
|
||||
`POST /api/admin/auth/login`; it does not place the credential in a URL or store
|
||||
it in browser storage.
|
||||
|
||||
Successful authentication creates the administrative session cookie and sends
|
||||
the browser to `/admin`. The `/admin` server-side loader validates that cookie
|
||||
before loading administrative data. A valid session is not sufficient by
|
||||
itself: the existing `/admin` IP allowlist remains an additional restriction,
|
||||
and a valid administrator outside the allowed network is sent to `/403`.
|
||||
|
||||
The administrative interface provides a **Sign out** control which calls
|
||||
`POST /api/admin/auth/logout`, clears the cookie, and returns the browser to
|
||||
`/admin/login`. Sessions expire after 20 minutes and expired, invalid, or
|
||||
missing sessions are redirected to the login page.
|
||||
|
||||
## Required server-side configuration
|
||||
|
||||
@@ -38,6 +49,42 @@ administrative secrets fail closed.
|
||||
continue verifying signature and expiry on every request.
|
||||
- This is shared-credential authentication. A valid token proves knowledge of
|
||||
the shared credential, not the identity of a named administrator.
|
||||
- Protecting `/admin` prevents its server-side Prisma, storage, and CRM data
|
||||
loading from running without a valid administrative session. It does not by
|
||||
itself protect browser-addressable API routes.
|
||||
|
||||
## Administrative API protection limitations
|
||||
|
||||
The current administrative UI directly uses API routes that do not yet enforce
|
||||
the administrative session, including:
|
||||
|
||||
- `/api/admin/getnewappeals_api`
|
||||
- `/api/admin/getlatestdocuments_api`
|
||||
- `/api/admin/getStatusCountsByAppeal_api`
|
||||
- `/api/admin/getStatusCountsByAppealAndLPA_api`
|
||||
|
||||
The appeals and documents routes expose paging operations used after the page
|
||||
has loaded. The status routes expose administrative dashboard reads. These
|
||||
routes retain their existing relay token and HMAC behaviour but have no
|
||||
independent administrative-session authorization. A later authorised stage
|
||||
must enforce the administrative session on privileged API routes and account
|
||||
for both browser calls and the existing server-side bootstrap callers.
|
||||
|
||||
Storage download, representation editing, queue actions, and draft deletion
|
||||
also retain their existing authorization behaviour in this stage. In
|
||||
particular, the original cross-container deletion risk is not remediated by the
|
||||
administrative page login and remains a separate mitigation boundary.
|
||||
|
||||
Directly observed storage routes include:
|
||||
|
||||
- `/api/file/getrepsblobproxy`, which forwards a caller-supplied container using
|
||||
server relay credentials and path signing.
|
||||
- `/api/file/editRepJson`, which performs a direct blob mutation and has no
|
||||
visible administrative-session or HMAC check.
|
||||
- `/api/file/downloadblob` and `/api/file/createrepcompletemessage_api`, which
|
||||
enforce existing path-HMAC checks but not administrative authorization.
|
||||
- `/api/file/deleteblobcase` and `/api/file/deleteblobrep`, whose existing
|
||||
cross-container deletion behaviour is intentionally unchanged in this stage.
|
||||
|
||||
## Deployment requirements before production use
|
||||
|
||||
|
||||
Reference in New Issue
Block a user