diff --git a/app/Actions/Auth/AuthenticateOidcUser.php b/app/Actions/Auth/AuthenticateOidcUser.php index bf70f98..eefa51e 100644 --- a/app/Actions/Auth/AuthenticateOidcUser.php +++ b/app/Actions/Auth/AuthenticateOidcUser.php @@ -16,11 +16,11 @@ class AuthenticateOidcUser public function execute(OidcUserData $data): User { // Search by subject claim - $user = User::where('oidc_sub', $data->sub)->first(); + $user = User::query()->where('oidc_sub', $data->sub)->first(); if (! $user) { // Fallback: search by email to map existing accounts - $user = User::where('email', $data->email)->first(); + $user = User::query()->where('email', $data->email)->first(); if ($user) { // Link account diff --git a/app/Http/Controllers/OidcController.php b/app/Http/Controllers/OidcController.php index 1286a43..9ba5646 100644 --- a/app/Http/Controllers/OidcController.php +++ b/app/Http/Controllers/OidcController.php @@ -7,7 +7,6 @@ use Illuminate\Auth\AuthenticationException; use Illuminate\Support\Facades\Auth; use Laravel\Socialite\Facades\Socialite; - use Symfony\Component\HttpFoundation\Response; class OidcController extends Controller diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 29bcaa1..0e3ca02 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -28,9 +28,10 @@ public function boot(): void { $this->configureDefaults(); - Event::listen(function (SocialiteWasCalled $event) { - $event->extendSocialite('oidc', OIDCExtendSocialite::class); - }); + Event::listen( + SocialiteWasCalled::class, + OIDCExtendSocialite::class + ); } /** diff --git a/tests/Feature/Auth/OidcAuthenticationTest.php b/tests/Feature/Auth/OidcAuthenticationTest.php index 85199fb..b0c5bff 100644 --- a/tests/Feature/Auth/OidcAuthenticationTest.php +++ b/tests/Feature/Auth/OidcAuthenticationTest.php @@ -3,10 +3,21 @@ use App\Models\User; use Laravel\Socialite\Facades\Socialite; use Laravel\Socialite\Two\User as SocialiteUser; +use SocialiteProviders\OIDC\Provider; beforeEach(function () { - // Clear oidc services config to mock config checks - config(['services.oidc.client_id' => 'mock_client_id']); + // Mock oidc services config + config([ + 'services.oidc.client_id' => 'mock_client_id', + 'services.oidc.client_secret' => 'mock_client_secret', + 'services.oidc.redirect' => 'https://mock-app.com/auth/oidc/callback', + 'services.oidc.base_url' => 'https://mock-oidc-provider.com', + ]); +}); + +test('oidc socialite driver resolves to the correct provider class', function () { + $driver = Socialite::driver('oidc'); + expect($driver)->toBeInstanceOf(Provider::class); }); test('oidc login button is visible on login page when configured', function () {