add token revoke and panic lockdown endpoints with security logging

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 00:48:44 +00:00
co-authored by Claude Opus 4.8
parent b96b23d92b
commit fcee091b53
9 changed files with 71 additions and 42 deletions
+5 -2
View File
@@ -2,7 +2,7 @@ import type { MiddlewareHandler } from 'hono';
import { verify } from '@@/jwt';
import * as errors from '@@/custom-errors';
import { isOriginAllowed } from './origin-validation';
import { isLockdown } from '../api/auth/distress';
import { isLockdown, noteBlocked } from '../api/auth/panic';
import { getUserById, isTokenBlacklisted } from 'officerdb';
// Role permissions: which HTTP methods each role can use
@@ -23,7 +23,10 @@ function isMethodAllowed(role: string | null, method: string): boolean {
export const userMiddleware: MiddlewareHandler = async function (ctx, next) {
// Duress lockdown: reject every authenticated request, cutting off all existing sessions.
if (isLockdown()) throw errors.UNAUTHORIZED();
if (isLockdown()) {
noteBlocked(`${ctx.req.method} ${ctx.req.path}`);
throw errors.UNAUTHORIZED();
}
const { authorization } = ctx.req.header();