Download the PHP package bambolee-digital/laravel-firebase-id-token without Composer
On this page you can find all versions of the php package bambolee-digital/laravel-firebase-id-token. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bambolee-digital/laravel-firebase-id-token
More information about bambolee-digital/laravel-firebase-id-token
Files in bambolee-digital/laravel-firebase-id-token
Package laravel-firebase-id-token
Short Description Firebase ID Token authentication for Laravel
License MIT
Informations about the package laravel-firebase-id-token
Laravel Firebase ID Token Authentication
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
- 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
You can install the package via composer:
Configuration
Publish the configuration file:
This will create a bambolee-firebase.php
configuration file in your config
directory.
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:
If you need to customize the migration, you can publish it:
Then, you can modify the migration file in your database/migrations
directory before running php artisan migrate
.
Updating User Model
After adding the external_id
column, make sure to add it to the $fillable
array in your User model:
Firebase Credentials
Set your Firebase credentials in your .env
file:
You can generate this by base64 encoding your Firebase service account JSON file:
Configuration Options
In config/bambolee-firebase.php
, you can customize various settings:
Usage
Setting up the Guard
In your config/auth.php
file, add the Firebase guard:
Protecting Routes
You can use the auth.configurable
middleware to protect your routes:
This middleware will attempt authentication using the order specified in your configuration.
Manual Authentication
You can manually authenticate a user using the Firebase guard:
Custom Claims
You can map custom claims from Firebase to your user model by specifying them in the configuration:
This will map the 'firebase_role' claim from the Firebase token to the 'role' attribute of your user model.
Sanctum Integration
If you're using Sanctum, you can configure token expiration and name:
This will create a Sanctum token for the user after successful Firebase authentication.
Testing
Changelog
Please see CHANGELOG.md for more information on what has changed recently.
Contributing
Please see CONTRIBUTING.md for details.
Security Vulnerabilities
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Kellvem Barbosa
- All Contributors
License
The MIT License (MIT). Please see License File for more information.# laravel-firebase-id-token