Skip to content

Instantly share code, notes, and snippets.

@shin1x1
Created March 17, 2015 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shin1x1/e979bf76c305513c7089 to your computer and use it in GitHub Desktop.
Save shin1x1/e979bf76c305513c7089 to your computer and use it in GitHub Desktop.
CSRF Protection Filter for Laravel 4 with AngularJS
<?php
Route::filter(
'csrf',
function () {
$token = Request::header('X-XSRF-TOKEN');
if (empty($token)) {
$token = Input::get('_token');
}
if (Session::token() !== $token) {
throw new Illuminate\Session\TokenMismatchException;
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment