-
-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathPrivilegesCache.inc
More file actions
36 lines (29 loc) · 1.2 KB
/
PrivilegesCache.inc
File metadata and controls
36 lines (29 loc) · 1.2 KB
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
<?php
namespace RESTAPI\Caches;
require_once 'RESTAPI/autoloader.inc';
use RESTAPI\Core\Cache;
use function RESTAPI\Core\Tools\get_classes_from_namespace;
/**
* Defines a Cache that is responsible for obtaining the privileges for REST API Endpoints and Forms and caching them
* to a centralized location where it can be read by /etc/inc/priv/restapi.priv.inc.
*/
class PrivilegesCache extends Cache {
/**
* Loop through each Endpoint and Cache objects and generate privileges for them.
*/
public function get_data_to_cache(): array {
# Use a variable to keep track of the privileges associated with this endpoint
$privs = [];
# Obtain privileges for each Endpoint class
foreach (get_classes_from_namespace('\\RESTAPI\\Endpoints\\') as $endpoint_class) {
$endpoint_object = new $endpoint_class();
$privs += $endpoint_object->generate_pfsense_privs();
}
# Obtain privileges for each Form class
foreach (get_classes_from_namespace('\\RESTAPI\\Forms\\') as $form_class) {
$form_object = new $form_class();
$privs += $form_object->generate_pfsense_privs();
}
return $privs;
}
}