Skip to content

Kobo-one/laravel-google-authenticate

 
 

Repository files navigation

GoogleAuthenticator

This module gives you the option to log in with Google that is coupled to a specific domain. It will give that user the Admin Role in return.

Installation

Via Composer

$ composer require statikbe/laravel-google-authenticate

Usage

The package will automatically register itself.

You can publish the migration and config with following command:

php artisan vendor:publish --provider="Statikbe\GoogleAuthenticate\GoogleAuthenticateServiceProvider"

To add the needed columns in your database run:

php artisan migrate

Add the use HasGoogleAuth trait in your User.php class. This will provide the necessary fillable options to your User.

in your .env file you should include the following keys:

AUTH_ROLE_ADMIN="Admin" //This can be any role you like
AUTH_ROLE_DOMAIN="domain.com"
AUGHT_REDIRECT_URL="/admin"
GOOGLE_CLIENT_ID="YOUR_GOOGLE_CLIENT_ID"
GOOGLE_CLIENT_SECRET="YOUR_GOOGLE_CLIENT_SECRET"
CALLBACK_URL_GOOGLE="https://www.domain.com/login/google/callback"

The last step is to add the following lines in your services.php

‘google’ => [
       ‘client_id’ => env(‘GOOGLE_CLIENT_ID’),
       ‘client_secret’ => env(‘GOOGLE_CLIENT_SECRET’),
       ‘redirect’ => env(‘CALLBACK_URL_GOOGLE’),
   ],

Info on how to create a Google Auth Client id and secret can be found on their documentation page.

Security

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

License

The MIT License (MIT). Please see License file for more information.

About

Google Authentication in Laravel

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%