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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user