-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathauthentication.php
70 lines (55 loc) · 2.61 KB
/
authentication.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
require_once(__DIR__.'/vendor/autoload.php');
require_once(INCLUDE_DIR.'class.plugin.php');
require_once('config.php');
class OpenIDAuthMS extends Plugin {
var $config_class = "OpenIDAuthMSPluginConfig";
function bootstrap() {
$config = $this->getConfig();
$clientAccess = $config->get('PLUGIN_ENABLED_CLIENT');
$staffAccess = $config->get('PLUGIN_ENABLED_STAFF');
if ($staffAccess) {
require_once('openid_ms.php');
StaffAuthenticationBackend::register(
new MicrosoftOpenIDStaffAuthBackend($this->getConfig()));
}
if ($clientAccess) {
require_once('openid_ms.php');
UserAuthenticationBackend::register(
new MicrosoftOpenIDClientAuthBackend($this->getConfig()));
}
$this->bootstrapAvatarSource($config);
}
private function bootstrapAvatarSource($config) {
$tenantId = $config->get('TENANT_ID');
$clientId = $config->get('CLIENT_ID');
$clientSecret = $config->get('CLIENT_SECRET');
$allowedDomains = explode(',', $config->get('ALLOWED_AVATAR_DOMAINS'));
// Cannot activate this feature if the required configuration keys are missing
if (is_null($tenantId) || is_null($clientId) || is_null($clientSecret)) {
return;
}
// Set up caching using the local filesystem
$filesystemAdapter = new League\Flysystem\Adapter\Local('/tmp/osticket');
$filesystem = new League\Flysystem\Filesystem($filesystemAdapter);
$filesystemPool = new Cache\Adapter\Filesystem\FilesystemCachePool($filesystem);
$credentialsCachePool = $filesystemPool;
// Use APCu for in-memory caching of the access token, if possible
if (function_exists('apcu_enabled') && apcu_enabled()) {
$apcuPool = new Cache\Adapter\Apcu\ApcuCachePool();
$credentialsCachePool = new Cache\Adapter\Chain\CachePoolChain([$apcuPool, $filesystemPool]);
}
require_once('microsoft_graph.php');
$clientApp = new ConfidentialClientApplication($tenantId, $clientId, $clientSecret, $credentialsCachePool);
require_once('avatar_source.php');
require_once('avatar_loader.php');
$avatarLoader = new AvatarLoader($filesystemPool, $clientApp, $allowedDomains);
$avatarLoader->bootstrap();
}
}
require_once(INCLUDE_DIR.'UniversalClassLoader.php');
use Symfony\Component\ClassLoader\UniversalClassLoader_osTicket;
$loader = new UniversalClassLoader_osTicket();
$loader->registerNamespaceFallbacks(array(
dirname(__file__).'/lib'));
$loader->register();