summaryrefslogtreecommitdiffstats
path: root/src/Authz.php
blob: 57de1c601a201cdf0a9d17739aa3ea96bcc2e0ff (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
<?php

namespace Jasny;

/**
 * Authorization
 */
interface Authz
{
    /**
     * Get all authz roles
     *  
     * @return array
     */
    public function getRoles();
    
    /**
     * Check if the current user is logged in and has specified role.
     * 
     * <code>
     *   if (!$auth->is('manager')) {
     *     http_response_code(403); // Forbidden
     *     echo "You are not allowed to view this page";
     *     exit();
     *   }
     * </code>
     * 
     * @param string $role
     * @return boolean
     */
    public function is($role);
}