import app from '@adonisjs/core/services/app' import { defineConfig } from '@adonisjs/shield' const shieldConfig = defineConfig({ /** * Configure CSP policies for your app. Refer documentation * to learn more */ csp: { enabled: true, directives: { defaultSrc: ["'self'"], scriptSrc: ["'self'", "'unsafe-inline'"], // unsafe-inline required for Inertia.js page props styleSrc: ["'self'", "'unsafe-inline'"], imgSrc: ["'self'", 'data:', 'blob:'], connectSrc: ["'self'"], fontSrc: ["'self'"], objectSrc: ["'none'"], frameSrc: ["'none'"], baseUri: ["'self'"], formAction: ["'self'"], }, reportOnly: false, }, /** * Configure CSRF protection options. Refer documentation * to learn more */ csrf: { enabled: true, // Exempt health check and SSE/transmit endpoints from CSRF exceptRoutes: ['/api/health', '/__transmit/events', '/__transmit/unsubscribe'], enableXsrfCookie: true, methods: ['POST', 'PUT', 'PATCH', 'DELETE'], }, /** * Control how your website should be embedded inside * iFrames */ xFrame: { enabled: true, action: 'DENY', }, /** * Force browser to always use HTTPS */ hsts: { enabled: app.inProduction, maxAge: '180 days', }, /** * Disable browsers from sniffing the content type of a * response and always rely on the "content-type" header. */ contentTypeSniffing: { enabled: true, }, }) export default shieldConfig