mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 00:34:44 +02:00
Add OAuth Settings to Settings (#839)
* Replace tabler icon package * Use new filled icons note: not everything has a filled icon * Add OAuth Settings to Settings Page * Fix authentik base url * replace hard coded oauth
This commit is contained in:
parent
23d515c3e5
commit
17805f676e
@ -28,6 +28,7 @@ use Filament\Pages\Page;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Illuminate\Http\Client\Factory;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Notification as MailNotification;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@ -83,6 +84,10 @@ class Settings extends Page implements HasForms
|
||||
->label('Backup')
|
||||
->icon('tabler-box')
|
||||
->schema($this->backupSettings()),
|
||||
Tab::make('OAuth')
|
||||
->label('OAuth')
|
||||
->icon('tabler-brand-oauth')
|
||||
->schema($this->oauthSettings()),
|
||||
Tab::make('misc')
|
||||
->label('Misc')
|
||||
->icon('tabler-tool')
|
||||
@ -411,6 +416,74 @@ class Settings extends Page implements HasForms
|
||||
];
|
||||
}
|
||||
|
||||
private function oauthSettings(): array
|
||||
{
|
||||
$oauthProviders = Config::get('auth.oauth');
|
||||
|
||||
$formFields = [];
|
||||
|
||||
foreach ($oauthProviders as $providerName => $providerConfig) {
|
||||
$providerEnvPrefix = strtoupper($providerName);
|
||||
|
||||
$fields = [
|
||||
Toggle::make("OAUTH_{$providerEnvPrefix}_ENABLED")
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->onIcon('tabler-check')
|
||||
->offIcon('tabler-x')
|
||||
->live()
|
||||
->columnSpan(1)
|
||||
->label('Enabled')
|
||||
->default(env("OAUTH_{$providerEnvPrefix}_ENABLED", false)),
|
||||
];
|
||||
|
||||
if (array_key_exists('client_id', $providerConfig['service'] ?? [])) {
|
||||
$fields[] = TextInput::make("OAUTH_{$providerEnvPrefix}_CLIENT_ID")
|
||||
->label('Client ID')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->password()
|
||||
->revealable()
|
||||
->autocomplete(false)
|
||||
->hidden(fn (Get $get) => !$get("OAUTH_{$providerEnvPrefix}_ENABLED"))
|
||||
->default(env("OAUTH_{$providerEnvPrefix}_CLIENT_ID", $providerConfig['service']['client_id'] ?? ''))
|
||||
->placeholder('Client ID');
|
||||
}
|
||||
|
||||
if (array_key_exists('client_secret', $providerConfig['service'] ?? [])) {
|
||||
$fields[] = TextInput::make("OAUTH_{$providerEnvPrefix}_CLIENT_SECRET")
|
||||
->label('Client Secret')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->password()
|
||||
->revealable()
|
||||
->autocomplete(false)
|
||||
->hidden(fn (Get $get) => !$get("OAUTH_{$providerEnvPrefix}_ENABLED"))
|
||||
->default(env("OAUTH_{$providerEnvPrefix}_CLIENT_SECRET", $providerConfig['service']['client_secret'] ?? ''))
|
||||
->placeholder('Client Secret');
|
||||
}
|
||||
|
||||
if (array_key_exists('base_url', $providerConfig['service'] ?? [])) {
|
||||
$fields[] = TextInput::make("OAUTH_{$providerEnvPrefix}_BASE_URL")
|
||||
->label('Base URL')
|
||||
->columnSpanFull()
|
||||
->autocomplete(false)
|
||||
->hidden(fn (Get $get) => !$get("OAUTH_{$providerEnvPrefix}_ENABLED"))
|
||||
->default(env("OAUTH_{$providerEnvPrefix}_BASE_URL", ''))
|
||||
->placeholder('Base URL');
|
||||
}
|
||||
|
||||
$formFields[] = Section::make(ucfirst($providerName))
|
||||
->columns(5)
|
||||
->icon($providerConfig['icon'] ?? 'tabler-brand-oauth')
|
||||
->collapsed(fn () => !env("OAUTH_{$providerEnvPrefix}_ENABLED", false))
|
||||
->collapsible()
|
||||
->schema($fields);
|
||||
}
|
||||
|
||||
return $formFields;
|
||||
}
|
||||
|
||||
private function miscSettings(): array
|
||||
{
|
||||
return [
|
||||
|
4
composer.lock
generated
4
composer.lock
generated
@ -13973,7 +13973,7 @@
|
||||
],
|
||||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [],
|
||||
"stability-flags": {},
|
||||
"prefer-stable": true,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
@ -13984,6 +13984,6 @@
|
||||
"ext-pdo": "*",
|
||||
"ext-zip": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"platform-dev": {},
|
||||
"plugin-api-version": "2.6.0"
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ return [
|
||||
// Default providers
|
||||
'facebook' => [
|
||||
'enabled' => env('OAUTH_FACEBOOK_ENABLED'),
|
||||
'icon' => 'tabler-brand-facebook',
|
||||
'icon' => 'tabler-brand-facebook-f',
|
||||
'color' => Color::hex('#1877f2'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_FACEBOOK_CLIENT_ID'),
|
||||
@ -38,7 +38,7 @@ return [
|
||||
],
|
||||
'x' => [
|
||||
'enabled' => env('OAUTH_X_ENABLED'),
|
||||
'icon' => 'tabler-brand-x',
|
||||
'icon' => 'tabler-brand-x-f',
|
||||
'color' => Color::hex('#1da1f2'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_X_CLIENT_ID'),
|
||||
@ -47,7 +47,7 @@ return [
|
||||
],
|
||||
'linkedin' => [
|
||||
'enabled' => env('OAUTH_LINKEDIN_ENABLED'),
|
||||
'icon' => 'tabler-brand-linkedin',
|
||||
'icon' => 'tabler-brand-linkedin-f',
|
||||
'color' => Color::hex('#0a66c2'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_LINKEDIN_CLIENT_ID'),
|
||||
@ -56,7 +56,7 @@ return [
|
||||
],
|
||||
'google' => [
|
||||
'enabled' => env('OAUTH_GOOGLE_ENABLED'),
|
||||
'icon' => 'tabler-brand-google',
|
||||
'icon' => 'tabler-brand-google-f',
|
||||
'color' => Color::hex('#4285f4'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_GOOGLE_CLIENT_ID'),
|
||||
@ -65,7 +65,7 @@ return [
|
||||
],
|
||||
'github' => [
|
||||
'enabled' => env('OAUTH_GITHUB_ENABLED'),
|
||||
'icon' => 'tabler-brand-github',
|
||||
'icon' => 'tabler-brand-github-f',
|
||||
'color' => Color::hex('#4078c0'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_GITHUB_CLIENT_ID'),
|
||||
@ -83,7 +83,7 @@ return [
|
||||
],
|
||||
'bitbucket' => [
|
||||
'enabled' => env('OAUTH_BITBUCKET_ENABLED'),
|
||||
'icon' => 'tabler-brand-bitbucket',
|
||||
'icon' => 'tabler-brand-bitbucket-f',
|
||||
'color' => Color::hex('#205081'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_BITBUCKET_CLIENT_ID'),
|
||||
@ -114,7 +114,7 @@ return [
|
||||
],
|
||||
'discord' => [
|
||||
'enabled' => env('OAUTH_DISCORD_ENABLED'),
|
||||
'icon' => 'tabler-brand-discord',
|
||||
'icon' => 'tabler-brand-discord-f',
|
||||
'color' => Color::hex('#5865F2'),
|
||||
'service' => [
|
||||
'client_id' => env('OAUTH_DISCORD_CLIENT_ID'),
|
||||
@ -124,7 +124,7 @@ return [
|
||||
],
|
||||
'steam' => [
|
||||
'enabled' => env('OAUTH_STEAM_ENABLED'),
|
||||
'icon' => 'tabler-brand-steam',
|
||||
'icon' => 'tabler-brand-steam-f',
|
||||
'color' => Color::hex('#00adee'),
|
||||
'service' => [
|
||||
'client_secret' => env('OAUTH_STEAM_CLIENT_SECRET'),
|
||||
|
Loading…
x
Reference in New Issue
Block a user