diff --git a/app/Extensions/OAuth/Providers/AuthentikProvider.php b/app/Extensions/OAuth/Providers/AuthentikProvider.php index da8e6e5a1..d87377ffb 100644 --- a/app/Extensions/OAuth/Providers/AuthentikProvider.php +++ b/app/Extensions/OAuth/Providers/AuthentikProvider.php @@ -4,10 +4,13 @@ namespace App\Extensions\OAuth\Providers; use Filament\Forms\Components\ColorPicker; use Filament\Forms\Components\TextInput; +use Illuminate\Foundation\Application; use SocialiteProviders\Authentik\Provider; final class AuthentikProvider extends OAuthProvider { + public function __construct(protected Application $app) {} + public function getId(): string { return 'authentik'; @@ -61,8 +64,8 @@ final class AuthentikProvider extends OAuthProvider return env('OAUTH_AUTHENTIK_DISPLAY_COLOR') ?? '#fd4b2d'; } - public static function register(): self + public static function register(Application $app): self { - return new self(); + return new self($app); } } diff --git a/app/Extensions/OAuth/Providers/CommonProvider.php b/app/Extensions/OAuth/Providers/CommonProvider.php index 9526ddf49..db48ff03c 100644 --- a/app/Extensions/OAuth/Providers/CommonProvider.php +++ b/app/Extensions/OAuth/Providers/CommonProvider.php @@ -2,11 +2,13 @@ namespace App\Extensions\OAuth\Providers; +use Illuminate\Foundation\Application; + final class CommonProvider extends OAuthProvider { - protected function __construct(private string $id, private ?string $providerClass, private ?string $icon, private ?string $hexColor) + protected function __construct(protected Application $app, private string $id, private ?string $providerClass, private ?string $icon, private ?string $hexColor) { - parent::__construct(); + parent::__construct($app); } public function getId(): string @@ -29,8 +31,8 @@ final class CommonProvider extends OAuthProvider return $this->hexColor; } - public static function register(string $id, ?string $providerClass = null, ?string $icon = null, ?string $hexColor = null): static + public static function register(Application $app, string $id, ?string $providerClass = null, ?string $icon = null, ?string $hexColor = null): static { - return new self($id, $providerClass, $icon, $hexColor); + return new self($app, $id, $providerClass, $icon, $hexColor); } } diff --git a/app/Extensions/OAuth/Providers/DiscordProvider.php b/app/Extensions/OAuth/Providers/DiscordProvider.php index cf98f8a08..2e672d3d2 100644 --- a/app/Extensions/OAuth/Providers/DiscordProvider.php +++ b/app/Extensions/OAuth/Providers/DiscordProvider.php @@ -5,6 +5,7 @@ namespace App\Extensions\OAuth\Providers; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Wizard\Step; +use Illuminate\Foundation\Application; use Illuminate\Support\HtmlString; use Illuminate\Support\Str; use SocialiteProviders\Discord\Provider; @@ -12,6 +13,8 @@ use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction; final class DiscordProvider extends OAuthProvider { + public function __construct(protected Application $app) {} + public function getId(): string { return 'discord'; @@ -51,8 +54,8 @@ final class DiscordProvider extends OAuthProvider return '#5865F2'; } - public static function register(): self + public static function register(Application $app): self { - return new self(); + return new self($app); } } diff --git a/app/Extensions/OAuth/Providers/GithubProvider.php b/app/Extensions/OAuth/Providers/GithubProvider.php index b8f4852b8..909cbda3b 100644 --- a/app/Extensions/OAuth/Providers/GithubProvider.php +++ b/app/Extensions/OAuth/Providers/GithubProvider.php @@ -5,12 +5,15 @@ namespace App\Extensions\OAuth\Providers; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Wizard\Step; +use Illuminate\Foundation\Application; use Illuminate\Support\HtmlString; use Illuminate\Support\Str; use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction; final class GithubProvider extends OAuthProvider { + public function __construct(protected Application $app) {} + public function getId(): string { return 'github'; @@ -50,8 +53,8 @@ final class GithubProvider extends OAuthProvider return '#4078c0'; } - public static function register(): self + public static function register(Application $app): self { - return new self(); + return new self($app); } } diff --git a/app/Extensions/OAuth/Providers/OAuthProvider.php b/app/Extensions/OAuth/Providers/OAuthProvider.php index a068df639..477851a71 100644 --- a/app/Extensions/OAuth/Providers/OAuthProvider.php +++ b/app/Extensions/OAuth/Providers/OAuthProvider.php @@ -4,6 +4,7 @@ namespace App\Extensions\OAuth\Providers; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Wizard\Step; +use Illuminate\Foundation\Application; use Illuminate\Support\Facades\Event; use Illuminate\Support\Str; use SocialiteProviders\Manager\SocialiteWasCalled; @@ -17,10 +18,12 @@ abstract class OAuthProvider return $id ? static::$providers[$id] : static::$providers; } - protected function __construct() + protected function __construct(protected Application $app) { if (array_key_exists($this->getId(), static::$providers)) { - logger()->warning("Tried to create duplicate OAuth provider with id '{$this->getId()}'"); + if (!$this->app->runningUnitTests()) { + logger()->warning("Tried to create duplicate OAuth provider with id '{$this->getId()}'"); + } return; } diff --git a/app/Extensions/OAuth/Providers/SteamProvider.php b/app/Extensions/OAuth/Providers/SteamProvider.php index 267af540a..2553e5f46 100644 --- a/app/Extensions/OAuth/Providers/SteamProvider.php +++ b/app/Extensions/OAuth/Providers/SteamProvider.php @@ -5,11 +5,14 @@ namespace App\Extensions\OAuth\Providers; use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Wizard\Step; +use Illuminate\Foundation\Application; use Illuminate\Support\HtmlString; use SocialiteProviders\Steam\Provider; final class SteamProvider extends OAuthProvider { + public function __construct(protected Application $app) {} + public function getId(): string { return 'steam'; @@ -67,8 +70,8 @@ final class SteamProvider extends OAuthProvider return '#00adee'; } - public static function register(): self + public static function register(Application $app): self { - return new self(); + return new self($app); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index cbea575c4..0d8970b4a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -86,19 +86,19 @@ class AppServiceProvider extends ServiceProvider Scramble::registerApi('remote', ['api_path' => 'api/remote', 'info' => ['version' => '1.0']])->afterOpenApiGenerated($bearerTokens); // Default OAuth providers included with Socialite - CommonProvider::register('facebook', null, 'tabler-brand-facebook-f', '#1877f2'); - CommonProvider::register('x', null, 'tabler-brand-x-f', '#1da1f2'); - CommonProvider::register('linkedin', null, 'tabler-brand-linkedin-f', '#0a66c2'); - CommonProvider::register('google', null, 'tabler-brand-google-f', '#4285f4'); - GithubProvider::register(); - CommonProvider::register('gitlab', null, 'tabler-brand-gitlab', '#fca326'); - CommonProvider::register('bitbucket', null, 'tabler-brand-bitbucket-f', '#205081'); - CommonProvider::register('slack', null, 'tabler-brand-slack', '#6ecadc'); + CommonProvider::register($app, 'facebook', null, 'tabler-brand-facebook-f', '#1877f2'); + CommonProvider::register($app, 'x', null, 'tabler-brand-x-f', '#1da1f2'); + CommonProvider::register($app, 'linkedin', null, 'tabler-brand-linkedin-f', '#0a66c2'); + CommonProvider::register($app, 'google', null, 'tabler-brand-google-f', '#4285f4'); + GithubProvider::register($app); + CommonProvider::register($app, 'gitlab', null, 'tabler-brand-gitlab', '#fca326'); + CommonProvider::register($app, 'bitbucket', null, 'tabler-brand-bitbucket-f', '#205081'); + CommonProvider::register($app, 'slack', null, 'tabler-brand-slack', '#6ecadc'); // Additional OAuth providers from socialiteproviders.com - AuthentikProvider::register(); - DiscordProvider::register(); - SteamProvider::register(); + AuthentikProvider::register($app); + DiscordProvider::register($app); + SteamProvider::register($app); FilamentColor::register([ 'danger' => Color::Red,