mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-19 06:41:23 +02:00
Assorted changes from recent sessions: - .gitignore: add mana-sync binary, Forgejo data - chat/web: add isSidebarMode to navigation store - clock/web: fix alarm page markup - contacts/mukke/presi/questions: add svelte.config.js aliases - context/web: add missing dependency - manacore/landing: update pricing page - manacore/web + todo/web: update mana dashboard pages - planta/web: fix dashboard layout - pnpm-lock.yaml: cleanup after backend removals - docs/APP_GAP_ANALYSIS.md: new gap analysis doc - services/mana-analytics: add Dockerfile - services/mana-subscriptions: new Go subscription service Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
715 B
TypeScript
26 lines
715 B
TypeScript
/**
|
|
* Service-to-Service Authentication Middleware
|
|
*
|
|
* Validates X-Service-Key header for backend-to-backend calls.
|
|
* Used by /internal/* routes.
|
|
*/
|
|
|
|
import type { MiddlewareHandler } from 'hono';
|
|
import { UnauthorizedError } from '../lib/errors';
|
|
|
|
/**
|
|
* Middleware that validates X-Service-Key header.
|
|
* Sets c.set('appId', ...) from X-App-Id header.
|
|
*/
|
|
export function serviceAuth(serviceKey: string): MiddlewareHandler {
|
|
return async (c, next) => {
|
|
const key = c.req.header('X-Service-Key');
|
|
if (!key || key !== serviceKey) {
|
|
throw new UnauthorizedError('Invalid or missing service key');
|
|
}
|
|
|
|
const appId = c.req.header('X-App-Id') || 'unknown';
|
|
c.set('appId', appId);
|
|
await next();
|
|
};
|
|
}
|