Warning
This is not an official product of YUMEMI Inc.
Authentication guard on Laravel for verifying requests from Google IAP (Identity-Aware Proxy).
- PHP 8.1 or later
- ext-gmp for JWT verification
- Laravel 9, 10, or 11 (dev)
-
Require this package as a dependency.
composer require yumemi-inc/google-iap-laravel
-
Implement
GoogleUserResolver
as you need.<?php // app/Security/AppGoogleUserResolver.php (new) use Illuminate\Contracts\Auth\Authenticatable; use Illuminate\Contracts\Auth\UserProvider; use YumemiInc\GoogleIapLaravel\Claims; use YumemiInc\GoogleIapLaravel\GoogleUserResolver; class AppGoogleUserResolver implements GoogleUserResolver { public function provide(Claims $claims, UserProvider $userProvider): ?Authenticatable { return $userProvider->retrieveByCredentials([ 'google_user_id' => $claims->id(), ]); } }
-
Register the user resolver as a service.
<?php // app/Providers/AppServiceProvider.php use YumemiInc\GoogleIapLaravel\GoogleUserResolver; public function register(): void { $this->app->bind(GoogleUserProvider::class, AppGoogleUserProvider::class); }
-
Use the guard provided in this package.
<?php // config/auth.php 'guards' => [ 'google-iap' => [ 'driver' => 'google-iap', 'provider' => 'users', ], ]