Download the PHP package sdwru/laravel-firebase-auth-plus without Composer

On this page you can find all versions of the php package sdwru/laravel-firebase-auth-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-firebase-auth-plus

laravel-firebase-auth-plus

Secure your laravel API with Google Firebase Auth

Adding the Middleware to your Laravel API will ensure that access is only granted by using a valid bearer token issued by Goggle Firebase Auth.

The main difference between this package and the package we forked it from is that we are using laravel-firebase as a dependency. Using laravel-firebase instead of firebase-tokens removes the need for a service provider since it is already included in laravel-firebase. Since that package depends on firebase-php, you can also use all the feature firebase-php provides.

Role middleware

This package includes optional role middleware for more granular access.

Install

laravel-firebase

Publish the laravel-firebase ServiceProvider (Provider: Kreait\Laravel\Firebase\ServiceProvider) if not already done so.

Configure laravel-firebase according to their instructions and also explained in the official firebase documentation at this link.

Those instructions make it sound more complicated than it is. All we need to do is generate a JSON file as follows:

  1. In the Firebase console, open Settings > Service Accounts.
  2. Click Generate New Private Key, then confirm by clicking Generate Key.
  3. Securely store the generated JSON file and add a reference to that file in your laravel .env file. The following example assumes we are storing the file in the root folder of our laravel installation. Rename it to whatever you want.

How to use

There are two ways to use this.

Method 1. Lock all access without JWT token

Add the Middleware on your app/Http/Kernel.php file.

Refer to the Laravel Middleware documentation on where you can put this in your Kernel.php file and how it can be used in routes.

Method 2 (recommended) using an authentication guard.

Add the Guard to app/Providers/AuthServiceProvider.php in the boot method.

In config/auth.php set your api guard driver to firebase and the model to LaravelFirebaseAuth\User::class

Add authentication to api routes in routes/api.php.

Example: Retrieve uid (For method #2 only) from API UserController

Example: Check if logged in and retrieve firebase user object and uid (For method #2 only) from almost anywhere inside Laravel

Role Middleware

To use this optional feature add the following to app/Http/Kernel.php.

Add role to user example

Please note, the client needs to be issued a new token for the new role to take effect. This can happen in one of 3 ways according to the documentation. The user signs in or re-authenticates, the user session gets it's ID token refreshed after an older token expires, and ID token is force refreshed by calling currentUser.getIdToken(true) on the client end in Javascript/Vue/React etc.

Routes

After assigning roles on the firebase end, add them to routes/api.php.

Role references

The property where we assign roles is referred to as custom claims in the following documentation.

https://firebase.google.com/docs/auth/admin/custom-claims

https://firebase.google.com/docs/firestore/solutions/role-based-access

https://firebase-php.readthedocs.io/en/5.x/user-management.html#custom-user-claims

https://www.toptal.com/firebase/role-based-firebase-authentication

Support

Feel free to open issues and provide feedback.


All versions of laravel-firebase-auth-plus with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
kreait/laravel-firebase Version ^2.0
illuminate/contracts Version ^5.8|^6.0|^7.0
illuminate/support Version ^5.8|^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sdwru/laravel-firebase-auth-plus contains the following files

Loading the files please wait ....