2017 © Pedro Peláez
 

library google-auth

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

image

maer/google-auth

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  • Tuesday, June 3, 2014
  • by maer
  • Repository
  • 0 Watchers
  • 0 Stars
  • 83 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Google Auth for Laravel 4

Add Google auth quick and painless in your Laravel 4 application. It is basically a wrapper for the thephpleague/oauth2-client package. The original package is dead simple to use, but this package adds a simple access control., (*1)

You can decide which Google accounts/domains are allowed or blocked. Well, I have used this several times anyway and it's been handy. It's as easy as eating pancakes!, (*2)

Installation

Best way is to use composer., (*3)

Add the following to your composer.json:, (*4)

{
    "require": {
        "maer/google-auth": "dev-master"
    }
}

You can, and should, change dev-master to the current latest., (*5)

Setup

Register the service provider in app/config/app.php:, (*6)

'providers' => array(
    'Maer\GoogleAuth\ServiceProvider',
)

Configuration

Publish and edit the configuration file, (*7)

$ php artisan config:publish maer/google-auth

Edit the app/config/packages/maer/google-auth/config.php:, (*8)

return array(

    'client_id'    => 'YOUR_GOOGLE_CLIENT_ID',
    'secret'       => 'YOUR_GOOGLE_CLIENT_SECRET',
    'callback_url' => 'YOUR_GOOGLE_CLIENT_CALLBACK_URL',

    /*
    * Allowed accounts
    * -------------------------------------
    * Enter full e-mail addresses or entire domains.
    * If empty, all e-mail addresses will be allowed.
    */
    'allow'     => array('your-email@a-domain.com', 'another-domain.com'),

    /*
    * Disallowed accounts
    * -------------------------------------
    * Enter full e-mail addresses or entire domains.
    * If an e-mail or domain is in the allowed and disallowed,
    * it will be blocked.
    */
    'disallow'     => array('not-allowed@another-domain.com'),
);

Usage

This is a simple example of how you use it. You should put this in a controller with depency injection instead., (*9)

Route::get('/', function()
{
    echo '<a href="/google-auth">Authorize</a>';
});

Route::get('/google-auth', function(){

    // Get the instance of GoogleAuth
    $Auth = App::make('Maer\GoogleAuth\GoogleAuth');

    // This call will redirect the user to Googles Auth screen
    return $Auth->authorize();

});

Route::get('/google-auth/callback', function(){

    // Get the instance of GoogleAuth
    $Auth = App::make('Maer\GoogleAuth\GoogleAuth');

    // If the authorization fails, this method will return null.
    // Now it's up to you to decide what to do with the user object.
    $User = $Auth->callback();    

    // You can also ask for the access token, regardless if you use
    // the callback-method or not.
    $token = $Auth->getAccessToken();

});

The Versions

03/06 2014

dev-master

9999999-dev

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

03/06 2014

dev-develop

dev-develop

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

03/06 2014

0.5.0

0.5.0.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

22/05 2014

0.4.0

0.4.0.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

16/05 2014

0.3.2

0.3.2.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

02/05 2014

0.3.1

0.3.1.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

27/04 2014

0.3.0

0.3.0.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2

18/04 2014

0.2

0.2.0.0

Laravel 4 wrapper for the league/oauth2-client package. Simple white/blacklist specific e-mails or entire domains.

  Sources   Download

The Requires

 

by Magnus Eriksson

laravel google oauth2