UNPKG

kibana-123

Version:

Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic

24 lines (18 loc) 709 B
import { badRequest } from 'boom'; export default function (kbnServer, server, config) { const disabled = config.get('server.xsrf.disableProtection'); const versionHeader = 'kbn-version'; const xsrfHeader = 'kbn-xsrf'; server.ext('onPostAuth', function (req, reply) { if (disabled) { return reply.continue(); } const isSafeMethod = req.method === 'get' || req.method === 'head'; const hasVersionHeader = versionHeader in req.headers; const hasXsrfHeader = xsrfHeader in req.headers; if (!isSafeMethod && !hasVersionHeader && !hasXsrfHeader) { return reply(badRequest(`Request must contain an ${xsrfHeader} header`)); } return reply.continue(); }); }