Welcome Guest, Not a member yet? Register   Sign In
Apply Filter to Route
#1

How do I use the csrf filter for a a specific route? I do not want it turned of for every route.
Simpler is always better
Reply
#2

Make sure that it's not in $globals, and then add the alias to public $filters:
App/Config/Filters.php
PHP Code:
/**
 * Configures aliases for Filter classes to
 * make reading things nicer and simpler.
 *
 * @var array
 */
 
public $aliases = [
 
'csrf'    => CSRF::class,
 
'toolbar'  => DebugToolbar::class
 ];
 
/**
 * List of filter aliases that are always
 * applied before and after every request.
 *
 * @var array
 */
 
public $globals = [
 
'before' => [
 
//'honeypot',
 //'csrf'
 
],
 
'after'  => [
 
'toolbar',
 
//'honeypot'
 
],
 ];

 
/**
 * List of filter aliases that should run on any
 * before or after URI patterns.
 *
 * Example:
 * 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
 *
 * @var array
 */
 
public $filters = [
 
'csrf' => ['before' => ['login/*''account/*, 'profiles/*']]
 ]; 
Reply
#3

Add options to the route ['filter' => 'csrf']
Reply




Theme © iAndrew 2016 - Forum software by © MyBB