laradevs / authremote
It is a component that allows to carry out and manage the authentication control through OAUTH2.0 for a Laravel application.
v1.1
2020-04-13 17:17 UTC
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^6.5
- illuminate/support: ^5.8|6.*|7.*
- socialiteproviders/laravelpassport: ^1.0
Requires (Dev)
- orchestra/testbench: ^3.5|^4.0|^5.0|^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-03-14 06:22:12 UTC
README
AUTH REMOTE
It is a component that allows to carry out and manage the authentication control through OAUTH2.0 for a Laravel application.
Installation
You can install the package via composer :
$ composer require laradevs/authremote
Next, You must register the service provider (optional) :
// config/app.php 'Providers' => [ // ... \LaraDevs\AuthRemote\MainServiceProvider::class, ]
Next, you must publish the configuration file to define the OAUTH server credentials:
php artisan vendor:publish --provider="LaraDevs\AuthRemote\MainServiceProvider"
This is the contents of the published file :
return [ 'uri' => env('USER_PROVIDER_REST_URL', ''), 'name_session_rest' => 'token_oauth', 'headers' => [], 'route_not_session'=>'start_route' ];
Set your URL Rest in .env
file :
APP_NAME="Laravel"
# ...
USER_PROVIDER_REST_URL=putYourRestURL
Add in Array Services
'laravelpassport' => [ 'client_id' => env('LARAVELPASSPORT_KEY','http://YOUR_ROUTE_HOST_SERVER/api/user'), 'client_secret' => env('LARAVELPASSPORT_SECRET'), 'redirect' => env('LARAVELPASSPORT_REDIRECT_URI'), 'host'=> env('LARAVELPASSPORT_HOST') ]
Add in Handle Exception in method render
if ($exception instanceof \LaraDevs\AuthRemote\RestException) { return redirect()->route(config('rest-provider.route_not_session')); }
Add in Array Auth
'providers' => [ 'users' => [ 'driver' => 'rest-users', 'model' => \LaraDevs\AuthRemote\User::class ], ]
Route Login & Logout published automatic
Route::get('/auth-remote/{provider}', '\LaraDevs\AuthRemote\ActionsController@redirectToProvider')->name('laravel_passport'); Route::get('/auth-remote/{provider}/callback', '\LaraDevs\AuthRemote\ActionsController@handleProviderCallback'); Route::post('/auth-remote-logout','\LaraDevs\AuthRemote\ActionsController@logout')->name('laravel_passport.logout');
Add route name for initial route
Route::get('/', function () { return view('welcome'); })->name(config('rest-provider.route_not_session'));