Skip to content

Commit

Permalink
another isSafeMethod usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Mar 3, 2020
1 parent e7829d9 commit a5c12a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/server/http/lifecycle_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { OnPostAuthHandler } from './lifecycle/on_post_auth';
import { OnPreResponseHandler } from './lifecycle/on_pre_response';
import { HttpConfig } from './http_config';
import { isSafeMethod } from './router';
import { Env } from '../config';
import { LifecycleRegistrar } from './http_server';

Expand All @@ -39,11 +40,10 @@ export const createXsrfPostAuthHandler = (config: HttpConfig): OnPostAuthHandler
return toolkit.next();
}

const isSafeMethod = request.route.method === 'get' || request.route.method === 'head';
const hasVersionHeader = VERSION_HEADER in request.headers;
const hasXsrfHeader = XSRF_HEADER in request.headers;

if (!isSafeMethod && !hasVersionHeader && !hasXsrfHeader) {
if (!isSafeMethod(request.route.method) && !hasVersionHeader && !hasXsrfHeader) {
return response.badRequest({ body: `Request must contain a ${XSRF_HEADER} header.` });
}

Expand Down

0 comments on commit a5c12a8

Please sign in to comment.