dev-master
9999999-devLVConnect OAuth2 Provider for Laravel Socialite
MIT
The Requires
- php >= 7.0
- socialiteproviders/manager ^3.3
by Mathieu TUDISCO
Wallogit.com
2017 © Pedro Peláez
LVConnect OAuth2 Provider for Laravel Socialite
LVConnect is a project that aims to unify login over all Linkvalue apps with an authentication service based on OAuth2., (*1)
Linkvalue is a french web/mobile agency., (*2)
Socialite is a simple and convenient way to authenticate users with OAuth providers for Laravel., (*3)
This package is an internal tool. You can download it and use it as an example for making your own, but it will be unusable if you're not a Linkvalue partner., (*4)
This assumes that you have composer installed globally, (*5)
composer require mathieutu/lvconnect-socialite
You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command artisan config:cache) all config is still available., (*6)
config/services.php. 'lvconnect' => [
'client_id' => env('LVCONNECT_ID'),
'client_secret' => env('LVCONNECT_SECRET'),
'redirect' => env('LVCONNECT_CALLBACK'),
],
If you want to do some test with another url that production one, you can optionally add an url key with the base url:, (*7)
'url' => 'https://lvconnect-staging.herokuapp.com',
.env / environment variables:Create your application in the LVConnect website and fill the information in your env:, (*8)
LVCONNECT_ID=XXXX LVCONNECT_SECRET=XXXX LVCONNECT_CALLBACK=http://my-full-website-url.localhost/login/callback
See Laravel docs on socialite usage., (*9)
return $socialite->driver('lvconnect')->redirect();
You can publish all the auth scaffolding with the following command:, (*10)
php artisan lvconnect:publish
You can set whether or not you want to use the provider as stateless. LVConnect supports whatever option you choose., (*11)
Note: If you are using this with Lumen, all providers will automatically be stateless since Lumen does not keep track of state., (*12)
// to turn off stateless
return Socialite::with('lvconnect')->stateless(false)->redirect();
// to use stateless
return Socialite::with('lvconnect')->stateless()->redirect();
The user that socialite will provide has this shape:, (*13)
User {#341 ▼
+accessTokenResponseBody: array:6 [▼
"access_token" => "0bc47e47-1e88-4d08-a402-1cd7c235de3d"
"token_type" => "bearer"
"expires_in" => 172800
"refresh_token" => "73a17012-b999-4300-8d4d-99e8675abc08"
"scope" => array:3 [▼
0 => "users:get"
1 => "users:modify"
2 => "profile:get"
]
"need_password_change" => false
]
+token: "0bc47e47-1e88-4d08-a402-1cd7c235de3d"
+refreshToken: "73a17012-b999-4300-8d4d-99e8675abc08"
+expiresIn: 172800
+id: "589ae9cfe2eb1d0009790659"
+nickname: null
+name: "Foo BAR"
+email: "foo.bar@link-value.fr"
+avatar: "https://www.gravatar.com/avatar/d5763d35fe855464633ff3ec5064ecad?s=200"
+user: array:10 [▼
"tags" => []
"roles" => array:5 [▼
0 => "tech"
1 => "business"
2 => "hr"
3 => "board"
4 => "com"
]
"firstName" => "Foo"
"lastName" => "BAR"
"email" => "foo.bar@link-value.fr"
"createdAt" => "2017-02-08T09:50:07.813Z"
"city" => "Lyon"
"description" => "A really good friend!"
"profilePictureUrl" => "https://www.gravatar.com/avatar/d5763d35fe855464633ff3ec5064ecad?s=200"
"id" => "589ae9cfe2eb1d0009790659"
]
}
It's a instance of \Laravel\Socialite\Two\User class., (*14)
This LVConnect Socialite package is an open-sourced software licensed under the MIT license., (*15)
Issues and PRs are obviously welcomed and encouraged, for features as well as documentation., (*16)
LVConnect OAuth2 Provider for Laravel Socialite
MIT