本文整理汇总了PHP中Csrf::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Csrf::check方法的具体用法?PHP Csrf::check怎么用?PHP Csrf::check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csrf
的用法示例。
在下文中一共展示了Csrf::check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitted
function submitted()
{
if (parent::submitted() && isset($_POST['_csrf'])) {
return Csrf::check($_POST['_csrf'], $this->intent);
} else {
return False;
}
}
示例2: function
/**
* Admin actions
*/
Route::action('auth', function () {
if (Auth::guest()) {
return Response::redirect('admin/login');
}
});
Route::action('guest', function () {
if (Auth::user()) {
return Response::redirect('admin/accueil');
}
});
Route::action('csrf', function () {
if (Request::method() == 'POST') {
if (!Csrf::check(Input::get('token'))) {
Notify::error(array('Invalid token'));
return Response::redirect('admin/login');
}
}
});
/**
* Admin routing
*/
Route::get('admin', function () {
if (Auth::guest()) {
return Response::redirect('admin/login');
}
return Response::redirect('admin/accueil');
});
/*
示例3: function
/*
|--------------------------------------------------------------------------
| CSRF Protection Filter
|--------------------------------------------------------------------------
|
| The CSRF filter is responsible for protecting your application against
| cross-site request forgery attacks. If this special token in a user
| session does not match the one given in this request, we'll bail.
|
*/
Route::filter('csrf', function () {
if (Request::isMethod('get') || Request::isMethod('options')) {
return;
}
// throws exception if token invalid
Csrf::check();
});
/*
|--------------------------------------------------------------------------
| X-Frame-Options Header Filter
|--------------------------------------------------------------------------
|
| Prevents pages being loaded in an iframe.
|
*/
Route::filter('setXFrameOptionsHeader', function ($route, $request, $response) {
if (method_exists($response, "header")) {
$response->header("X-Frame-Options", "deny");
}
});
/*