PHP Classes

File: tests/_rbac_guard_denied.php

Recommend this page to a friend!
  Packages of Adrian M   PHP CRUD API Generator   tests/_rbac_guard_denied.php   Download  
File: tests/_rbac_guard_denied.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP CRUD API Generator
Create an API to access MySQL database record
Author: By
Last change:
Date: 3 months ago
Size: 365 bytes
 

Contents

Class file image Download
<?php
require_once __DIR__ . '/../vendor/autoload.php';

use
App\Security\Rbac;
use
App\Security\RbacGuard;

$roles = [ 'viewer' => ['*' => ['read']] ];
$userRoles = [];
$rbac = new Rbac($roles, $userRoles);
$guard = new RbacGuard($rbac);

// Expect 403 and exit
$guard->guard(true, 'viewer', 'posts', 'delete');

echo
"should not reach here\n"; // shouldn't print