-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathApplication.php
More file actions
83 lines (68 loc) · 2.67 KB
/
Application.php
File metadata and controls
83 lines (68 loc) · 2.67 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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
declare(strict_types=1);
namespace OCA\Solid\AppInfo;
use OC;
use OC\AppConfig;
use OCA\Solid\Service\SolidWebhookService;
use OCA\Solid\Db\SolidWebhookMapper;
use OCA\Solid\Middleware\SolidCorsMiddleware;
use OCA\Solid\ClientAuth;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\Server;
class Application extends App implements IBootstrap {
public const APP_ID = 'solid';
public static $userSubDomainsEnabled;
/**
* @param array $urlParams
*/
public function __construct(array $urlParams = []) {
$request = \OCP\Server::get(\OCP\IRequest::class);
$rawPathInfo = $request->getRawPathInfo();
if ($rawPathInfo == '/apps/solid/token') {
$backend = new \OCA\Solid\ClientAuth();
\OC::$server->getUserManager()->registerBackend($backend);
}
parent::__construct(self::APP_ID, $urlParams);
}
public function register(IRegistrationContext $context): void {
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\OpenIdConfigurationHandler::class);
$context->registerWellKnownHandler(\OCA\Solid\WellKnown\SolidHandler::class);
$context->registerMiddleware(SolidCorsMiddleware::class);
/**
* Core class wrappers
*/
$context->registerService('UserService', function($c) {
return new \OCA\Solid\Service\UserService(
$c->query('UserSession')
);
});
$context->registerService('UserSession', function($c) {
return $c->query('ServerContainer')->getUserSession();
});
// currently logged in user, userId can be gotten by calling the
// getUID() method on it
$context->registerService('User', function($c) {
return $c->query('UserSession')->getUser();
});
/* webhook DB services */
$context->registerService(SolidWebhookService::class, function($c): SolidWebhookService {
return new SolidWebhookService(
$c->query(SolidWebhookMapper::class)
);
});
$context->registerService(SolidWebhookMapper::class, function($c): SolidWebhookMapper {
return new SolidWebhookMapper(
$c->get(\OCP\IDBConnection::class)
);
});
}
public function boot(IBootContext $context): void {
self::$userSubDomainsEnabled = OC::$server->get(AppConfig::class)->getValueBool(self::APP_ID, 'userSubDomainsEnabled');
require_once(__DIR__.'/../../vendor/autoload.php');
}
}