|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Autumn\JWTAuth; |
|
4
|
|
|
|
|
5
|
|
|
use App; |
|
6
|
|
|
use Illuminate\Foundation\AliasLoader; |
|
7
|
|
|
use System\Classes\PluginBase; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* JWTAuth Plugin Information File. |
|
11
|
|
|
*/ |
|
12
|
|
|
class Plugin extends PluginBase |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var array Plugin dependencies |
|
16
|
|
|
*/ |
|
17
|
|
|
public $require = ['RainLab.User']; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Returns information about this plugin. |
|
21
|
|
|
* |
|
22
|
|
|
* @return array |
|
23
|
|
|
*/ |
|
24
|
|
|
public function pluginDetails() |
|
25
|
|
|
{ |
|
26
|
|
|
return [ |
|
27
|
|
|
'name' => 'JWTAuth', |
|
28
|
|
|
'description' => 'JSON Web Token Authentication.', |
|
29
|
|
|
'author' => 'Autumn', |
|
30
|
|
|
'icon' => 'icon-user-secret', |
|
31
|
|
|
]; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Register method, called when the plugin is first registered. |
|
36
|
|
|
* |
|
37
|
|
|
* @return void |
|
38
|
|
|
*/ |
|
39
|
|
|
public function register() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->app['config']['jwt'] = require(__DIR__.'/config/jwt.php'); |
|
42
|
|
|
$this->app['config']['api'] = require(__DIR__.'/config/api.php'); |
|
43
|
|
|
|
|
44
|
|
|
$this->app->register(\Dingo\Api\Provider\LaravelServiceProvider::class); |
|
45
|
|
|
$this->app->register(\Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class); |
|
46
|
|
|
|
|
47
|
|
|
$alias = AliasLoader::getInstance(); |
|
48
|
|
|
$alias->alias('JWTAuth', \Tymon\JWTAuth\Facades\JWTAuth::class); |
|
49
|
|
|
$alias->alias('JWTFactory', \Tymon\JWTAuth\Facades\JWTFactory::class); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Boot method, called right before the request route. |
|
54
|
|
|
* |
|
55
|
|
|
* @return array |
|
56
|
|
|
*/ |
|
57
|
|
|
public function boot() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->app->register(\Autumn\JWTAuth\Providers\JWTServiceProvider::class); |
|
60
|
|
|
|
|
61
|
|
|
$this->app['Dingo\Api\Auth\Auth']->extend('jwt', function ($app) { |
|
62
|
|
|
return new \Dingo\Api\Auth\Provider\JWT($app['Tymon\JWTAuth\JWTAuth']); |
|
63
|
|
|
}); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|