summaryrefslogtreecommitdiff
path: root/app/Core/Security/Authorization.php
blob: a04b37208fe758f5edcd70bccb3c92d6efc2fd26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

namespace Kanboard\Core\Security;

/**
 * Authorization Handler
 *
 * @package  security
 * @author   Frederic Guillot
 */
class Authorization
{
    /**
     * Access Map
     *
     * @access private
     * @var AccessMap
     */
    private $acl;

    /**
     * Constructor
     *
     * @access public
     * @param  AccessMap  $acl
     */
    public function __construct(AccessMap $acl)
    {
        $this->acl = $acl;
    }

    /**
     * Check if the given role is allowed to access to the specified resource
     *
     * @access public
     * @param  string  $controller
     * @param  string  $method
     * @param  string  $role
     * @return boolean
     */
    public function isAllowed($controller, $method, $role)
    {
        $roles = $this->acl->getRoles($controller, $method);
        return in_array($role, $roles);
    }
}