LocalGroupsRepository.php 3.1 KB
Newer Older
1
2
3
4
5
<?php


namespace Source\Gateways\Groups;

6
7
8
use Source\Entities\Group;
use Source\Authorization\Permissions;

9
10
class LocalGroupsRepository extends InMemoryGroupsRepository
{
11
12
    public function __construct()
    {
13
        $this->create(static::getAdminGroup());
14

15
        $this->create(static::getManageUsersGroup());
16

17
        $this->create(static::getManageDoorsGroup());
18

19
        $this->create(static::getManageTokenGroup());
20

21
        $this->create(static::getTokenCreateGroup());
22

23
        $this->create(static::getCodeQueryGroup());
24

25
        $this->create(static::getComputerScienceMajorGroup());
26

27
        $this->create(static::getEngineeringLabAccessGroup());
Jacob Priddy's avatar
Jacob Priddy committed
28
29

        $this->create(static::getManageGroupsGroup());
30
31
32
33
34
    }

    /**
     * @return \Source\Entities\Group
     */
35
    public static function getAdminGroup(): Group
36
37
38
39
40
    {
        return new Group(
            1,
            Permissions::ADMIN,
            'Built in super power group with all permissions.'
41
        );
42
    }
43

44
45
46
    /**
     * @return \Source\Entities\Group
     */
47
    public static function getManageUsersGroup(): Group
48
49
50
51
52
    {
        return new Group(
            2,
            Permissions::MANAGE_USERS,
            'Gives the manage user permission'
53
        );
54
    }
55

56
57
58
    /**
     * @return \Source\Entities\Group
     */
59
    public static function getManageDoorsGroup(): Group
60
61
62
63
64
    {
        return new Group(
            3,
            Permissions::MANAGE_DOORS,
            'Gives the manage door permission'
65
        );
66
    }
67

68
69
70
    /**
     * @return \Source\Entities\Group
     */
71
    public static function getManageTokenGroup(): Group
72
73
    {
        return new Group(
74
75
76
            6,
            Permissions::MANAGE_TOKEN,
            'Gives the permission for one to manage delegation of API Tokens'
77
        );
78
    }
79

80
81
82
    /**
     * @return \Source\Entities\Group
     */
83
    public static function getTokenCreateGroup(): Group
84
85
    {
        return new Group(
86
87
88
            4,
            Permissions::TOKEN_CREATE,
            'Gives the permission to generate long lived API Tokens'
89
        );
90
    }
91

92
93
94
    /**
     * @return \Source\Entities\Group
     */
95
    public static function getCodeQueryGroup(): Group
96
97
    {
        return new Group(
98
99
100
            5,
            Permissions::CODE_QUERY,
            'Gives the permission to retrieve a user by doorcode.'
101
        );
102
    }
103

104
105
106
    /**
     * @return \Source\Entities\Group
     */
107
    public static function getComputerScienceMajorGroup(): Group
108
109
110
111
112
    {
        return new Group(
            7,
            'Computer Science Major',
            'Gives access to the CSLab, the STEM Lab, and the math conference room'
113
        );
114
    }
115

116
117
118
    /**
     * @return \Source\Entities\Group
     */
119
    public static function getEngineeringLabAccessGroup(): Group
120
121
122
123
124
    {
        return new Group(
            8,
            'Electrical Engineering Labs',
            'Gives access to the Electrical Engineering Labs'
125
126
        );
    }
Jacob Priddy's avatar
Jacob Priddy committed
127
128
129
130
131
132
133
134
135

    public static function getManageGroupsGroup(): Group
    {
        return new Group(
            9,
            Permissions::MANAGE_GROUPS,
            'Gives permission to manage stored groups'
        );
    }
136
}