-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore_init.php
40 lines (34 loc) · 1.08 KB
/
core_init.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
use Aura\Session\Session;
use Brave\CoreConnector\Bootstrap;
use Eve\Sso\AuthenticationProvider;
use Psr\Container\ContainerExceptionInterface;
require 'vendor/autoload.php';
const ROOT_DIR = __DIR__;
$bootstrap = new Bootstrap();
/** @var AuthenticationProvider $authenticationProvider */
try {
$authenticationProvider = $bootstrap->getContainer()->get(AuthenticationProvider::class);
} catch (ContainerExceptionInterface $e) {
error_log($e->getMessage());
die('Error 500.');
}
$cb = $_GET['cb'] ?? '';
/** @var Session $session */
try {
$session = $bootstrap->getContainer()->get(Session::class);
} catch (ContainerExceptionInterface $e) {
error_log($e->getMessage());
die('Error 500.');
}
try {
$state = $authenticationProvider->generateState('wiki');
} catch (Exception $e) {
error_log($e->getMessage());
exit();
}
$session->getSegment('Bravecollective_Neucore')->set('sso_state', $state);
$session->getSegment('Bravecollective_Neucore')->set('cb', $cb);
$loginUrl = $authenticationProvider->buildLoginUrl($state);
header('Location: ' . $loginUrl);
exit();