mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 11:39:26 +01:00
- CORS: restrict origin from wildcard '*' to app URL from env (prevents cross-origin requests from arbitrary sites) - Sessions: enable @adonisjs/session with cookie store and httpOnly/secure cookie flags; uncomment session middleware in kernel.ts - CSRF: enable shield CSRF protection (requires sessions); uses XSRF-TOKEN cookie mechanism compatible with Inertia.js/Axios; exempts /api/health and SSE transmit endpoints - CSP: enable Content Security Policy with restrictive directives (no object-src, no frame-src, self-only script/style/connect/font) - HSTS: enable HTTP Strict Transport Security in production only - Path traversal: tighten filenameParamValidator to block /, \, .., and shell special characters; reduce max length from 4096 to 255 - env: add URL to .env.example; uncomment SESSION_DRIVER validation in env.ts https://claude.ai/code/session_01WfRC4tDeYprykhMrg4PxX6
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
/*
|
|
|--------------------------------------------------------------------------
|
|
| HTTP kernel file
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| The HTTP kernel file is used to register the middleware with the server
|
|
| or the router.
|
|
|
|
|
*/
|
|
|
|
import router from '@adonisjs/core/services/router'
|
|
import server from '@adonisjs/core/services/server'
|
|
|
|
/**
|
|
* The error handler is used to convert an exception
|
|
* to an HTTP response.
|
|
*/
|
|
server.errorHandler(() => import('#exceptions/handler'))
|
|
|
|
/**
|
|
* The server middleware stack runs middleware on all the HTTP
|
|
* requests, even if there is no route registered for
|
|
* the request URL.
|
|
*/
|
|
server.use([
|
|
() => import('#middleware/container_bindings_middleware'),
|
|
() => import('@adonisjs/cors/cors_middleware'),
|
|
() => import('@adonisjs/vite/vite_middleware'),
|
|
() => import('@adonisjs/inertia/inertia_middleware'),
|
|
() => import('@adonisjs/static/static_middleware'),
|
|
() => import('#middleware/maps_static_middleware')
|
|
])
|
|
|
|
/**
|
|
* The router middleware stack runs middleware on all the HTTP
|
|
* requests with a registered route.
|
|
*/
|
|
router.use([
|
|
() => import('@adonisjs/core/bodyparser_middleware'),
|
|
() => import('@adonisjs/session/session_middleware'),
|
|
() => import('@adonisjs/shield/shield_middleware'),
|
|
])
|
|
|
|
/**
|
|
* Named middleware collection must be explicitly assigned to
|
|
* the routes or the routes group.
|
|
*/
|
|
export const middleware = router.named({})
|