its probably easier (for me) if i tell you how i do it :)
in index i have
$access=Access::instance(); //get instance of x35 class
$access->deny('/editPage','*'); //for route /editPage with asterix i deny every body
$access->allow('/editPage','editor'); // with this i allow editor to access the route
/editPage is a route its defined in routes.ini like so:
GET|POST /editPage=Edit->EditWeb
//the following is a before route class method defined in a class controller called "Edit which is in a file file called Edit.php which i have in api directory
function beforeRoute($f3)
{
$f3=Base::instance();
$f3->set('CASELESS',FALSE);
$access =Access::instance();
$access->authorize($f3->get('SESSION.role'));
//can temporarily disabled these so can playwith code
clearstatcache();
}
basically in the above i put caseless because i found , it was possible to get around access if somebody put for example
/ editpage as url , the next line gets an instance, the next line will either give true or false. if true ,it means somebody has successfully logged in & a session has been created $f3->get('SESSION.role') simply returns "editor" in my code. So as long as session is not empty and does return editor then access will be given .
can't remember why i put clearstatcache(); in there