-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcron.php
40 lines (33 loc) · 1.27 KB
/
cron.php
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
<?php
//if(PHP_SAPI !== 'cli') die('Server side only.');
ini_set('display_errors', 1);
require_once '../vendor/autoload.php';
require_once "includes/API.php";
require_once "includes/app.storage.php";
appStorage::connect();
$entities = appStorage::getAllSettings();
$app = new stdClass();
$app->OAuth2 = new stdClass();
$app->OAuth2->provider = new TheNetworg\OAuth2\Client\Provider\Azure([
'clientId' => getenv("Auth_appId"),
'clientSecret' => getenv("Auth_appSecret"),
'redirectUri' => getenv("Auth_redirectUri")
]);
foreach($entities as $entity) {
$tenantDomain = $entity->getPartitionKey();
$app->OAuth2->provider->tenant = $tenantDomain;
try {
$app->OAuth2->token = $app->OAuth2->provider->getAccessToken('client_credentials', ['resource' => "https://graph.windows.net/"]);
$accessGroups = json_decode($entity->getPropertyValue("accessGroups"));
$everyone = $entity->getPropertyValue("access") == "everyone" ? true : false;
$groups = array_merge($accessGroups->students, $accessGroups->faculty, $accessGroups->staff);
try {
API::assignToApplication($tenantDomain, $everyone, $groups);
} catch(\Exception $e) {
echo "--FAIL-- ".$e->getMessage()."\n\n";
}
} catch(\Exception $e) {
echo "--FAIL-- ".$e->getMessage()."\n\n";
}
}
?>