:octocat: Social OAuth authentication for Laravel 5 & 6. Drivers: Facebook, Twitter, Google, LinkedIn, Github, Bitbucket.
Social OAuth authentication for Laravel 5 which provides oAuth support in PHP 5.3+ and is very easy to integrate with any project which requires an oAuth client. This package use Laravel Socialite. For Laravel 4 look this package
The library supports OAuth 2.0 compliant services. A list of currently implemented services can be found below. More services will be implemented soon.
Included service implementations:
Laravel Support version
Laravel | laravel-oauth |
---|---|
<=5.5 | ^1.0 |
6.0 | ^1.1 |
$ composer require mckenziearts/laravel-oauth
Add the service provider to your config/app.php
providers array:
For Laravel 5.5.+ - you're done.
Mckenziearts\LaravelOAuth\LaravelOAuthServiceProvider::class,
php artisan vendor:publish --provider="Mckenziearts\LaravelOAuth\LaravelOAuthServiceProvider"
composer dump-autoload
When you published the vendor assets you added a new file inside of your config
folder which is called config/laravel-oauth.php
. This file contains a bunch of configuration you can use to configure your connexion using social networks.
First, you have to add your service like is defined on The official documentation of Socialite available here. Just setup your Oauth services for your application. Laravel/socialite is automatically installed by this package.
config/laravel-oauth.php
file you must define the default users table name to simplify migrations. By default users table is used'users' => [
'table' => 'users',
],
providers
array. To active a provider set the value to true
'providers' => [
'facebook' => true,
'google' => true,
'github' => true,
],
The last configuration is to stylize the button by editing class name and add or remove icon
Next, if you may want to re-publish the laravel-oauth assets, config, and the migrations run the following command:
php artisan vendor:publish --tag=laravel-oauth.assets --force
php artisan vendor:publish --tag=laravel-oauth.config --force
php artisan vendor:publish --tag=laravel-oauth.migrations --force
php artisan migrate
@yield('css')
login
to display the login text or resgister
for the text related to the registration@socialite('login')
@yield('css')
who defined in your master layout@section('css')
<link href="{{ url('/vendor/mckenziearts/laravel-oauth/assets/css/socialite.css') }}" rel="stylesheet">
@endsection
Auth\LoginController
of your application, add the OAuthSocialite
trait:namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Mckenziearts\LaravelOAuth\Traits\OAuthSocialite;
class LoginController extends Controller
{
use OAuthSocialite;
..
With this feature you can overwrite the present methods on the trait if you want to customize them even more
Route::get('/auth/{provider}', 'Auth\LoginController@redirectToProvider');
Route::get('/callback/{provider}', 'Auth\LoginController@handleProviderCallback');
Please see the changelog.md for more information on what has changed recently.
$ composer test
Please see contributing.md for details and a todolist.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
MIT. Please see the license.md for more information.