yumemi-inc / google-iap-laravel
Authentication guard on Laravel for verifying requests from Google IAP (Identity-Aware Proxy).
Installs: 2 094
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 8
Forks: 0
Open Issues: 1
Requires
- php: ^8.1
- google/auth: ^1.37
- illuminate/auth: ^9|^10|^11
- illuminate/contracts: ^9|^10|^11
- illuminate/http: ^9|^10|^11
- illuminate/support: ^9|^10|^11
- kelvinmo/simplejwt: ~0.7.0 || ~0.8.0 || dev-master
- symfony/cache: ^6.4 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.51
- nunomaduro/larastan: ^2.9
- orchestra/testbench: ^8.21
- phpstan/extension-installer: ^1.3
- quartetcom/static-analysis-kit: ~8.1.22
This package is auto-updated.
Last update: 2024-11-04 22:06:03 UTC
README
Warning
This is not an official product of YUMEMI Inc.
Authentication guard on Laravel for verifying requests from Google IAP (Identity-Aware Proxy).
Prerequisites
- PHP 8.1 or later
- ext-gmp for JWT verification
- Laravel 9, 10, or 11 (dev)
Getting Started
-
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', ], ]