1
|
|
|
<?php namespace Lahaxearnaud\U2f; |
2
|
|
|
|
3
|
|
|
use Illuminate\Routing\Router; |
4
|
|
|
use Illuminate\Support\ServiceProvider; |
5
|
|
|
|
6
|
|
|
class U2fServiceProvider extends ServiceProvider |
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Indicates if loading of the provider is deferred. |
10
|
|
|
* |
11
|
|
|
* @var bool |
12
|
|
|
*/ |
13
|
|
|
protected $defer = false; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Bootstrap the application events. |
17
|
|
|
* |
18
|
|
|
* @return void |
19
|
|
|
*/ |
20
|
|
|
public function boot(Router $router) |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
$routeConfig = [ |
23
|
|
|
'namespace' => '\Lahaxearnaud\U2f\Http\Controllers', |
24
|
|
|
'prefix' => '/u2f/', |
25
|
|
|
'middleware' => $this->app[ 'config' ]->get('u2f.authMiddlewareName', 'web') |
26
|
|
|
]; |
27
|
|
|
|
28
|
|
|
$this->app[ 'router' ]->group($routeConfig, function(Router $router) { |
29
|
|
|
$router->get('register', [ |
30
|
|
|
'uses' => 'U2fController@registerData', |
31
|
|
|
'as' => 'u2f.register.data', |
32
|
|
|
'middleware' => 'auth' |
33
|
|
|
]); |
34
|
|
|
$router->post('register', [ |
35
|
|
|
'uses' => 'U2fController@register', |
36
|
|
|
'as' => 'u2f.register', |
37
|
|
|
'middleware' => 'auth' |
38
|
|
|
]); |
39
|
|
|
|
40
|
|
|
$router->get('auth', [ |
41
|
|
|
'uses' => 'U2fController@authData', |
42
|
|
|
'as' => 'u2f.auth.data', |
43
|
|
|
'middleware' => 'auth' |
44
|
|
|
]); |
45
|
|
|
$router->post('auth', [ |
46
|
|
|
'uses' => 'U2fController@auth', |
47
|
|
|
'as' => 'u2f.auth', |
48
|
|
|
'middleware' => 'auth' |
49
|
|
|
]); |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
$this->publishes([ |
53
|
|
|
__DIR__.'/../database/migrations/' => base_path('/database/migrations') |
54
|
|
|
], 'u2f-migrations'); |
55
|
|
|
|
56
|
|
|
$this->publishes([ |
57
|
|
|
__DIR__.'/../config/u2f.php' => config_path('u2f.php') |
58
|
|
|
], 'u2f-config'); |
59
|
|
|
|
60
|
|
|
$this->publishes([ |
61
|
|
|
__DIR__.'/../resources/js' => public_path('vendor/u2f'), |
62
|
|
|
], 'u2f-components'); |
63
|
|
|
|
64
|
|
|
$this->publishes([ |
65
|
|
|
__DIR__.'/../views' => resource_path('views/vendor/u2f'), |
66
|
|
|
], 'u2f-views'); |
67
|
|
|
|
68
|
|
|
$this->loadViewsFrom(__DIR__.'/../views/', 'u2f'); |
69
|
|
|
$this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'u2f'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Register the service provider. |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
public function register() |
78
|
|
|
{ |
79
|
|
|
$app = $this->app; |
80
|
|
|
$this->app->bind('u2f', function() use ($app){ |
81
|
|
|
return new U2f($app->make('config'), $this->app->make('session')); |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get the services provided by the provider. |
87
|
|
|
* |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function provides() |
91
|
|
|
{ |
92
|
|
|
return [ 'u2f' ]; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.