Authorizer.php 1.9 KB
Newer Older
1
2
3
4
5
6
7
8
<?php


namespace Source\Authorization;

interface Authorizer
{
    /**
9
10
11
     * The user needs ALL of the permissions.
     *
     * @param string[] $permissions
12
     * @return bool
13
     * @throws \Source\Exceptions\EntityNotFoundException
14
     */
15
    public function allowsAll(array $permissions): bool;
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
     * The user needs only ONE of the permissions
     *
     * @param string[] $permissions
     * @return bool
     * @throws \Source\Exceptions\EntityNotFoundException
     */
    public function allowsOne(array $permissions): bool;

    /**
     * Permissions to check against from \Source\Authorization\Permissions
     * Te user needs ALL of the permissions
     *
     * @param string[] $permissions
     * @throws \Source\Exceptions\AuthorizationException
     * @throws \Source\Exceptions\EntityNotFoundException
     */
    public function protectAll(array $permissions): void;

    /**
     * Permissions to check against from \Source\Authorization\Permissions
     * The user only needs ONE of the permissions
     *
     * @param string[] $permissions
41
     * @throws \Source\Exceptions\AuthorizationException
42
     * @throws \Source\Exceptions\EntityNotFoundException
43
     */
44
    public function protectOne(array $permissions): void;
Jacob Priddy's avatar
Jacob Priddy committed
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64

    /**
     * Permissions to check against from \Source\Authorization\Permissions
     * The user needs the permission
     *
     * @param string $permission
     * @throws \Source\Exceptions\AuthorizationException
     * @throws \Source\Exceptions\EntityNotFoundException
     */
    public function protect(string $permission): void;

    /**
     * Protects the admin user from being modified.
     *
     * @param string      $userId
     * @param string|null $groupId
     * @throws \Source\Exceptions\AuthorizationException
     * @throws \Source\Exceptions\EntityNotFoundException
     */
    public function protectAdminRights(string $userId, ?string $groupId = null): void;
65
}