-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plugin.php
75 lines (64 loc) · 2.4 KB
/
Plugin.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
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
<?php
declare(strict_types=1);
namespace Vdlp\BasicAuthentication;
use Backend\Helpers\Backend as BackendHelper;
use Illuminate\Contracts\Http\Kernel;
use System\Classes\PluginBase;
use Vdlp\BasicAuthentication\Console\CreateCredentialsCommand;
use Vdlp\BasicAuthentication\Http\Middleware\BasicAuthenticationMiddleware;
use Vdlp\BasicAuthentication\ServiceProviders\BasicAuthenticationServiceProvider;
final class Plugin extends PluginBase
{
public function pluginDetails(): array
{
return [
'name' => 'vdlp.basicauthentication::lang.plugin.name',
'description' => 'vdlp.basicauthentication::lang.plugin.description',
'author' => 'Van der Let & Partners',
'icon' => 'icon-lock',
];
}
public function boot(): void
{
if (
(bool) config('basicauthentication.enabled', false) === false
|| $this->app->runningInConsole()
|| $this->app->runningUnitTests()
) {
return;
}
$this->app[Kernel::class]
->pushMiddleware(BasicAuthenticationMiddleware::class);
}
public function register(): void
{
$this->app->register(BasicAuthenticationServiceProvider::class);
$this->registerConsoleCommand(CreateCredentialsCommand::class, CreateCredentialsCommand::class);
}
public function registerPermissions(): array
{
return [
'vdlp.basicauthentication.access_settings' => [
'label' => 'vdlp.basicauthentication::lang.permissions.access_settings.label',
'tab' => 'vdlp.basicauthentication::lang.permissions.access_settings.tab',
],
];
}
public function registerSettings(): array
{
/** @var BackendHelper $backendHelper */
$backendHelper = resolve(BackendHelper::class);
return [
'credentials' => [
'label' => 'vdlp.basicauthentication::lang.settings.label',
'description' => 'vdlp.basicauthentication::lang.settings.description',
'url' => $backendHelper->url('vdlp/basicauthentication/credentials'),
'category' => 'Basic Authentication',
'icon' => 'icon-lock',
'permissions' => ['vdlp.basicauthentication.*'],
'keywords' => 'basic authentication security',
'order' => 500,
],
];
}
}