forked from pelican-dev/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPocketIDSchema.php
More file actions
95 lines (85 loc) · 3.23 KB
/
PocketIDSchema.php
File metadata and controls
95 lines (85 loc) · 3.23 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
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Ebnater\PocketIDProvider\Extensions\OAuth\Schemas;
use App\Extensions\OAuth\Schemas\OAuthSchema;
use Filament\Forms\Components\ColorPicker;
use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Wizard\Step;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\HtmlString;
use SocialiteProviders\PocketID\Provider;
final class PocketIDSchema extends OAuthSchema
{
public function getId(): string
{
return 'pocketid';
}
public function getSocialiteProvider(): string
{
return Provider::class;
}
public function getServiceConfig(): array
{
return array_merge(parent::getServiceConfig(), [
'base_url' => env('OAUTH_POCKETID_BASE_URL'),
]);
}
public function getSetupSteps(): array
{
return array_merge([
Step::make('Configure Pocket ID Application')
->schema([
TextEntry::make('instructions')
->hiddenLabel()
->state(new HtmlString(Blade::render('
<ol class="list-decimal list-inside space-y-1">
<li>Log in to your Pocket ID instance</li>
<li>Navigate to your application or create a new OAuth application</li>
<li>Copy the <strong>Client ID</strong> and <strong>Client Secret</strong> from your Pocket ID application</li>
<li>Configure the redirect URL shown below in your Pocket ID application settings</li>
</ol>
'))),
TextInput::make('_noenv_callback')
->label('Callback URL')
->dehydrated()
->disabled()
->default(fn () => url('/auth/oauth/callback/pocketid')),
]),
], parent::getSetupSteps());
}
public function getSettingsForm(): array
{
return array_merge(parent::getSettingsForm(), [
TextInput::make('OAUTH_POCKETID_BASE_URL')
->label('Base URL')
->placeholder('https://id.example.com')
->columnSpan(2)
->required()
->url()
->autocomplete(false)
->default(env('OAUTH_POCKETID_BASE_URL')),
TextInput::make('OAUTH_POCKETID_DISPLAY_NAME')
->label('Display Name')
->placeholder('Pocket ID')
->autocomplete(false)
->default(env('OAUTH_POCKETID_DISPLAY_NAME', 'Pocket ID')),
ColorPicker::make('OAUTH_POCKETID_DISPLAY_COLOR')
->label('Display Color')
->placeholder('#000000')
->default(env('OAUTH_POCKETID_DISPLAY_COLOR', '#000000'))
->hex(),
]);
}
public function getName(): string
{
return env('OAUTH_POCKETID_DISPLAY_NAME', 'Pocket ID');
}
public function getIcon(): string
{
return 'tabler-id';
}
public function getHexColor(): string
{
return env('OAUTH_POCKETID_DISPLAY_COLOR', '#000000');
}
}