diff --git a/src/FirebaseAuthenticationServiceProvider.php b/src/FirebaseAuthenticationServiceProvider.php index 3a46fb7..bd5d148 100644 --- a/src/FirebaseAuthenticationServiceProvider.php +++ b/src/FirebaseAuthenticationServiceProvider.php @@ -31,9 +31,15 @@ public function boot() public function register() { $this->app->singleton(Verifier::class, function ($app) { + $project = config('firebase.project_id', env('GOOGLE_CLOUD_PROJECT')); + + if (empty($project)) { + throw new \Exception('Missing GOOGLE_CLOUD_PROJECT env variable.'); + } + $keyStore = new HttpKeyStore(null, cache()->store()); - return new Verifier(config('firebase.project_id', env('GOOGLE_CLOUD_PROJECT')), $keyStore); + return new Verifier($project, $keyStore); }); } } diff --git a/src/FirebaseGuard.php b/src/FirebaseGuard.php index c5adc5b..91ab86a 100644 --- a/src/FirebaseGuard.php +++ b/src/FirebaseGuard.php @@ -35,6 +35,10 @@ public function user(Request $request) { $token = $request->bearerToken(); + if (empty($token)) { + return; + } + try { $token = $this->verifier->verifyIdToken($token);