PHPackages                             bambolee-digital/laravel-firebase-id-token - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. bambolee-digital/laravel-firebase-id-token

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

bambolee-digital/laravel-firebase-id-token
==========================================

Firebase ID Token authentication for Laravel

1.0.2(1y ago)120MITPHPPHP ^8.1

Since Sep 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Bambolee-Digital/laravel-firebase-id-token)[ Packagist](https://packagist.org/packages/bambolee-digital/laravel-firebase-id-token)[ Docs](https://github.com/bambolee-digital/laravel-firebase-id-token)[ RSS](/packages/bambolee-digital-laravel-firebase-id-token/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

Laravel Firebase ID Token Authentication
========================================

[](#laravel-firebase-id-token-authentication)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5002f7a486c404f4ae3d0dbb0ccfc51fc4eec827e7751fa2fd1de3cba45fa241/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62616d626f6c65652d6469676974616c2f6c61726176656c2d66697265626173652d69642d746f6b656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bambolee-digital/laravel-firebase-id-token)[![Total Downloads](https://camo.githubusercontent.com/825ec138c0394444fb182560ac9c775f65186971e9ec382309a8698fb5e005bc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62616d626f6c65652d6469676974616c2f6c61726176656c2d66697265626173652d69642d746f6b656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bambolee-digital/laravel-firebase-id-token)[![License](https://camo.githubusercontent.com/06776360b92164e26deb80e3493f0a3c1c254bc5edac806847a5a345d9c3e889/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62616d626f6c65652d6469676974616c2f6c61726176656c2d66697265626173652d69642d746f6b656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bambolee-digital/laravel-firebase-id-token)[![GitHub Tests Action Status](https://camo.githubusercontent.com/74f42fdbb0309d75cc08c34857272552c29940777bc6e5a93974f6aa2a6b93c1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62616d626f6c65652d6469676974616c2f6c61726176656c2d66697265626173652d69642d746f6b656e2f72756e2d74657374733f6c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/bambolee-digital/laravel-firebase-id-token/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/65b42850c960fbc95ff4a56aea3690a8c52fa63e22644053589199215a8cb4c8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f62616d626f6c65652d6469676974616c2f6c61726176656c2d66697265626173652d69642d746f6b656e2f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/bambolee-digital/laravel-firebase-id-token/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)

This package provides a seamless integration of Firebase ID Token authentication with Laravel, supporting both Laravel 10.x and 11.x. It allows you to easily authenticate users using Firebase ID tokens and optionally integrate with Laravel Sanctum for API token management.

Features
--------

[](#features)

- Firebase ID Token verification and user authentication
- Automatic user creation and updating based on Firebase data
- Configurable authentication order (Firebase and/or Sanctum)
- Custom claims mapping
- Sanctum integration for API token management
- Compatible with Laravel 10.x and 11.x

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require bambolee-digital/laravel-firebase-id-token
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="BamboleeDigital\LaravelFirebaseIdToken\Providers\FirebaseAuthServiceProvider" --tag="config"
```

This will create a `bambolee-firebase.php` configuration file in your `config` directory.

Database Migration
------------------

[](#database-migration)

This package requires an `external_id` column in your users table to store the Firebase User ID. A migration is included to add this column. To run the migration, execute:

```
php artisan migrate
```

If you need to customize the migration, you can publish it:

```
php artisan vendor:publish --provider="BamboleeDigital\LaravelFirebaseIdToken\Providers\FirebaseAuthServiceProvider" --tag="migrations"
```

Then, you can modify the migration file in your `database/migrations` directory before running `php artisan migrate`.

Updating User Model
-------------------

[](#updating-user-model)

After adding the `external_id` column, make sure to add it to the `$fillable` array in your User model:

```
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable
{
    use HasApiTokens;

    protected $fillable = [
        'name',
        'email',
        'password',
        'external_id', // Add this line
    ];

    // ...
}
```

### Firebase Credentials

[](#firebase-credentials)

Set your Firebase credentials in your `.env` file:

```
FIREBASE_CREDENTIALS_BASE64=your_base64_encoded_firebase_credentials

```

You can generate this by base64 encoding your Firebase service account JSON file:

```
base64 -i path/to/your/firebase-credentials.json
```

### Configuration Options

[](#configuration-options)

In `config/bambolee-firebase.php`, you can customize various settings:

```
return [
    'credentials_base64' => env('FIREBASE_CREDENTIALS_BASE64'),
    'auth_order' => env('AUTH_ORDER', 'firebase,sanctum'),
    'user_model' => \App\Models\User::class,
    'custom_claims' => [
        // 'role' => 'user_role',
    ],
    'auto_create_user' => true,
    'default_user_data' => [
        'name' => 'Dog Dot App User',
    ],
    'sanctum' => [
        'expiration' => null,
        'token_name' => 'firebase-auth-token',
    ],
];
```

Usage
-----

[](#usage)

### Setting up the Guard

[](#setting-up-the-guard)

In your `config/auth.php` file, add the Firebase guard:

```
'guards' => [
    // ...
    'firebase' => [
        'driver' => 'firebase',
        'provider' => 'users',
    ],
],
```

### Protecting Routes

[](#protecting-routes)

You can use the `auth.configurable` middleware to protect your routes:

```
Route::middleware(['auth.configurable'])->group(function () {
    Route::get('/user', function () {
        return Auth::user();
    });
});
```

This middleware will attempt authentication using the order specified in your configuration.

### Manual Authentication

[](#manual-authentication)

You can manually authenticate a user using the Firebase guard:

```
if (Auth::guard('firebase')->check()) {
    $user = Auth::guard('firebase')->user();
    // User is authenticated
}
```

### Custom Claims

[](#custom-claims)

You can map custom claims from Firebase to your user model by specifying them in the configuration:

```
'custom_claims' => [
    'role' => 'firebase_role',
],
```

This will map the 'firebase\_role' claim from the Firebase token to the 'role' attribute of your user model.

### Sanctum Integration

[](#sanctum-integration)

If you're using Sanctum, you can configure token expiration and name:

```
'sanctum' => [
    'expiration' => 60 * 24, // 24 hours
    'token_name' => 'firebase-auth-token',
],
```

This will create a Sanctum token for the user after successful Firebase authentication.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Kellvem Barbosa](https://github.com/kellvembarbosa)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.# laravel-firebase-id-token

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance44

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~83 days

Total

3

Last Release

445d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea0811b77232bb232cc41a918466de4b146044ce293582045f2df13eeeeffd7f?d=identicon)[bambolee-digital](/maintainers/bambolee-digital)

---

Top Contributors

[![kellvembarbosa](https://avatars.githubusercontent.com/u/3621135?v=4)](https://github.com/kellvembarbosa "kellvembarbosa (6 commits)")

---

Tags

laravelAuthenticationfirebaseID Token

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bambolee-digital-laravel-firebase-id-token/health.svg)

```
[![Health](https://phpackages.com/badges/bambolee-digital-laravel-firebase-id-token/health.svg)](https://phpackages.com/packages/bambolee-digital-laravel-firebase-id-token)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[olssonm/l5-very-basic-auth

Laravel stateless HTTP basic auth without the need for a database

1662.5M1](/packages/olssonm-l5-very-basic-auth)[andrewdwallo/filament-companies

A comprehensive Laravel authentication and authorization system designed for Filament, focusing on multi-tenant company management.

34450.0k2](/packages/andrewdwallo-filament-companies)[vinkas/firebase-auth-laravel

Firebase Authentication package for Laravel PHP Framework

392.1k](/packages/vinkas-firebase-auth-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
