-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.php
55 lines (43 loc) · 1.16 KB
/
boot.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
<?php
/**
* OpenTHC SSO Bootstrap
*
* SPDX-License-Identifier: MIT
*/
// declare(encoding='UTF-8');
// declare(strict_types=1);
define('APP_ROOT', __DIR__);
define('APP_BUILD', '420.23.244');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT & ~E_WARNING);
openlog('openthc-sso', LOG_ODELAY|LOG_PID, LOG_LOCAL0);
require_once(APP_ROOT . '/vendor/autoload.php');
if ( ! \OpenTHC\Config::init(APP_ROOT) ) {
_exit_html_fail('<h1>Invalid Application Configuration [ALB-035]</h1>', 500);
}
define('OPENTHC_SERVICE_ID', \OpenTHC\Config::get('openthc/sso/id'));
define('OPENTHC_SERVICE_ORIGIN', \OpenTHC\Config::get('openthc/sso/origin'));
// _error_handler_init();
/**
* Checks if we're in TEST mode
*/
function is_test_mode() {
// Cookie Check
if ( ! empty($_COOKIE['openthc-test'])) {
$sk1 = $_COOKIE['openthc-test'];
// Cookie Pattern Check
if (preg_match('/^[\w\-\+\/]{32,64}$/', $sk1)) {
// Config Check
$sk0 = \OpenTHC\Config::get('openthc/sso/test/sk');
if ( ! empty($sk0)) {
// Time Check
// if ($sk0 >= 48 hours old) {
// return false;
// }
if ($sk0 === $sk1) {
return true;
}
}
}
}
return false;
}