diff --git a/app/Extensions/OAuth/Schemas/AuthentikSchema.php b/app/Extensions/OAuth/Schemas/AuthentikSchema.php index 10e9be348..95f4fa935 100644 --- a/app/Extensions/OAuth/Schemas/AuthentikSchema.php +++ b/app/Extensions/OAuth/Schemas/AuthentikSchema.php @@ -4,6 +4,10 @@ namespace App\Extensions\OAuth\Schemas; 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\Authentik\Provider; final class AuthentikSchema extends OAuthSchema @@ -20,11 +24,27 @@ final class AuthentikSchema extends OAuthSchema public function getServiceConfig(): array { - return [ + return array_merge(parent::getServiceConfig(), [ 'base_url' => env('OAUTH_AUTHENTIK_BASE_URL'), - 'client_id' => env('OAUTH_AUTHENTIK_CLIENT_ID'), - 'client_secret' => env('OAUTH_AUTHENTIK_CLIENT_SECRET'), - ]; + ]); + } + + public function getSetupSteps(): array + { + return array_merge([ + Step::make('Create Authentik Application') + ->schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('
On your Authentik dashboard select Applications, then select Create with Provider.
On the creation step select OAuth2/OpenID Provider and on the configure step set Redirect URIs/Origins to the value below.
'))), + TextInput::make('_noenv_callback') + ->label('Callback URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/authentik')), + ]), + ], parent::getSetupSteps()); } public function getSettingsForm(): array diff --git a/app/Extensions/OAuth/Schemas/BitbucketSchema.php b/app/Extensions/OAuth/Schemas/BitbucketSchema.php new file mode 100644 index 000000000..5252d5372 --- /dev/null +++ b/app/Extensions/OAuth/Schemas/BitbucketSchema.php @@ -0,0 +1,45 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Visit the
For the Callback URL use the value below.
'))), + TextInput::make('_noenv_callback') + ->label('Callback URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/bitbucket')), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-bitbucket-f'; + } + + public function getHexColor(): string + { + return '#205081'; + } +} diff --git a/app/Extensions/OAuth/Schemas/FacebookSchema.php b/app/Extensions/OAuth/Schemas/FacebookSchema.php new file mode 100644 index 000000000..ded300a9b --- /dev/null +++ b/app/Extensions/OAuth/Schemas/FacebookSchema.php @@ -0,0 +1,48 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Visit the
Once selected go to Use Cases and customize "Authenticate and request data from users with Facebook Login", from there go to Settings and add Valid OAuth Redirect URIs using the value below.
'))), + TextInput::make('_noenv_callback') + ->label('Valid OAuth Redirect URIs') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/facebook')), + TextEntry::make('get_app_info') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('To obtain the OAuth values go to App Settings > Basic.
'))), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-facebook-f'; + } + + public function getHexColor(): string + { + return '#1877f2'; + } +} diff --git a/app/Extensions/OAuth/Schemas/GoogleSchema.php b/app/Extensions/OAuth/Schemas/GoogleSchema.php new file mode 100644 index 000000000..6cb74d367 --- /dev/null +++ b/app/Extensions/OAuth/Schemas/GoogleSchema.php @@ -0,0 +1,54 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Visit the
Navigate or search Credentials, click on the Create Credentials button and select OAuth client ID. On the Application type select Web Application.
On Authorized JavaScript origins and Authorized redirect URIs add and use the values below.
'))), + TextInput::make('_noenv_origin') + ->label('Authorized JavaScript origins') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('')), + TextInput::make('_noenv_callback') + ->label('Authorized redirect URIs') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/google')), + TextEntry::make('register_application') + ->hiddenLabel() + ->state(new HtmlString('When you filled all fields click on Create.
')), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-google-f'; + } + + public function getHexColor(): string + { + return '#4285f4'; + } +} diff --git a/app/Extensions/OAuth/Schemas/LinkedinSchema.php b/app/Extensions/OAuth/Schemas/LinkedinSchema.php new file mode 100644 index 000000000..26736c020 --- /dev/null +++ b/app/Extensions/OAuth/Schemas/LinkedinSchema.php @@ -0,0 +1,45 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Select the Auth tab and set Authorized redirect URLs for your app to the value below.
'))), + TextInput::make('_noenv_callback') + ->label('Authorized redirect URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/linkedin')), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-linkedin-f'; + } + + public function getHexColor(): string + { + return '#0a66c2'; + } +} diff --git a/app/Extensions/OAuth/Schemas/SlackSchema.php b/app/Extensions/OAuth/Schemas/SlackSchema.php new file mode 100644 index 000000000..78ae5445e --- /dev/null +++ b/app/Extensions/OAuth/Schemas/SlackSchema.php @@ -0,0 +1,45 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Navigate to the OAuth & Permissions section and configure the Redirect URL using the value below.
'))), + TextInput::make('_noenv_callback') + ->label('Redirect URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/slack')), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-slack'; + } + + public function getHexColor(): string + { + return '#6ecadc'; + } +} diff --git a/app/Extensions/OAuth/Schemas/XSchema.php b/app/Extensions/OAuth/Schemas/XSchema.php new file mode 100644 index 000000000..dfa6b616e --- /dev/null +++ b/app/Extensions/OAuth/Schemas/XSchema.php @@ -0,0 +1,54 @@ +schema([ + TextEntry::make('create_application') + ->hiddenLabel() + ->state(new HtmlString(Blade::render('Visit the
Go to the app\'s settings and set up User authentication if not yet. Make sure to select Web App as the type of app.
For the Callback URI / Redirect URL and Website URL set it using the value below.
'))), + TextInput::make('_noenv_origin') + ->label('Website URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('')), + TextInput::make('_noenv_callback') + ->label('Callback URI / Redirect URL') + ->dehydrated() + ->disabled() + ->hintCopy() + ->default(fn () => url('/auth/oauth/callback/x')), + TextEntry::make('register_application') + ->hiddenLabel() + ->state(new HtmlString('If you have already set this up go to your app\'s Keys and tokens and obtain the Client ID and Secret there.
')), + ]), + ], parent::getSetupSteps()); + } + + public function getIcon(): string + { + return 'tabler-brand-x'; + } + + public function getHexColor(): string + { + return '#1da1f2'; + } +} diff --git a/app/Providers/Extensions/OAuthServiceProvider.php b/app/Providers/Extensions/OAuthServiceProvider.php index 6d64ce496..abc619dcb 100644 --- a/app/Providers/Extensions/OAuthServiceProvider.php +++ b/app/Providers/Extensions/OAuthServiceProvider.php @@ -4,11 +4,16 @@ namespace App\Providers\Extensions; use App\Extensions\OAuth\OAuthService; use App\Extensions\OAuth\Schemas\AuthentikSchema; -use App\Extensions\OAuth\Schemas\CommonSchema; +use App\Extensions\OAuth\Schemas\BitbucketSchema; use App\Extensions\OAuth\Schemas\DiscordSchema; +use App\Extensions\OAuth\Schemas\FacebookSchema; use App\Extensions\OAuth\Schemas\GithubSchema; use App\Extensions\OAuth\Schemas\GitlabSchema; +use App\Extensions\OAuth\Schemas\GoogleSchema; +use App\Extensions\OAuth\Schemas\LinkedinSchema; +use App\Extensions\OAuth\Schemas\SlackSchema; use App\Extensions\OAuth\Schemas\SteamSchema; +use App\Extensions\OAuth\Schemas\XSchema; use Illuminate\Support\ServiceProvider; class OAuthServiceProvider extends ServiceProvider @@ -19,14 +24,14 @@ class OAuthServiceProvider extends ServiceProvider $service = new OAuthService(); // Default OAuth providers included with Socialite - $service->register(new CommonSchema('facebook', icon: 'tabler-brand-facebook-f', hexColor: '#1877f2')); - $service->register(new CommonSchema('x', icon: 'tabler-brand-x-f', hexColor: '#1da1f2')); - $service->register(new CommonSchema('linkedin', icon: 'tabler-brand-linkedin-f', hexColor: '#0a66c2')); - $service->register(new CommonSchema('google', icon: 'tabler-brand-google-f', hexColor: '#4285f4')); + $service->register(new FacebookSchema()); + $service->register(new XSchema()); + $service->register(new LinkedinSchema()); + $service->register(new GoogleSchema()); $service->register(new GithubSchema()); $service->register(new GitlabSchema()); - $service->register(new CommonSchema('bitbucket', icon: 'tabler-brand-bitbucket-f', hexColor: '#205081')); - $service->register(new CommonSchema('slack', icon: 'tabler-brand-slack', hexColor: '#6ecadc')); + $service->register(new BitbucketSchema()); + $service->register(new SlackSchema()); // Additional OAuth providers from socialiteproviders.com $service->register(new AuthentikSchema()); diff --git a/composer.lock b/composer.lock index fcc99afad..1196479f1 100644 --- a/composer.lock +++ b/composer.lock @@ -15231,7 +15231,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -15242,7 +15242,7 @@ "ext-pdo": "*", "ext-zip": "*" }, - "platform-dev": {}, + "platform-dev": [], "platform-overrides": { "php": "8.2" },