-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi.php
More file actions
25 lines (19 loc) · 737 Bytes
/
api.php
File metadata and controls
25 lines (19 loc) · 737 Bytes
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
<?php
$app->on('cockpit.api.authenticate', function($data) use($app) {
err('Checking user session', var_export($data, true));
if ($data['token'] && $data['resource'] == 'auth0') {
$user = $this->module('auth0')->userinfo($data['token'], [
'normalize' => true,
'cache' => $app->retrieve('config/auth0/cache', false)
]);
err('authentication middleware got user', var_export($user, true));
if ($user) {
$data['authenticated'] = true;
$data['user'] = $user;
}
}
err('Authenticate', var_export($data, true));
});
$app->on('cockpit.rest.init', function($routes) use($app) {
$routes['auth0'] = 'Auth0\\Controller\\RestApi';
});