Laravel plugin that helps authenticate with the upbond auth service
upbond/laravel-auth is a Laravel package for laravel plugin that helps authenticate with the upbond auth service.
It currently has 0 GitHub stars and 6.906 downloads on Packagist (latest version v2.0.6).
Install it with composer require upbond/laravel-auth.
Discover more Laravel packages by upbond
or browse all Laravel packages to compare alternatives.
Last updated
This package is inspired by Auth0
Please see the Laravel webapp quickstart for a complete guide on how to install this in an existing project or to download a pre-configured sample project. Additional documentation on specific scenarios is below.
$this->app->bind(
\Upbond\Auth\Login\Contract\AuthUserRepository::class,
\Upbond\Auth\Login\Repository\AuthUserRepository::class
);
In the register method of your AppServiceProvider add:
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Cache;
// ...
public function register()
{
// ...
$this->app->bind(
'\Auth\SDK\Helpers\Cache\CacheHandler',
function() {
static $cacheWrapper = null;
if ($cacheWrapper === null) {
$cache = Cache::store();
$cacheWrapper = new LaravelCacheWrapper($cache);
}
return $cacheWrapper;
});
}
$app->register(Upbond\Auth\Login\LoginServiceProvider::class);
UPBOND_API_URI=api.dev.upbond.io
You can implement your own cache strategy by creating a new class that implements the Auth\SDK\Helpers\Cache\CacheHandler contract, or just use the cache strategy you want by picking that store with Cache::store('your_store_name');
You can customize the way you handle the users in your application by creating your own UserRepository. This class should implement the Auth\Login\Contract\AuthUserRepository contract. Please see the Custom User Handling section of the Laravel Quickstart for the latest example.
To protect APIs using an access token generated by Auth, there is an upbond API guard provided (Laravel documentation on guards). To use this guard, add it to config/auth.php with the driver upbond:
'providers' => [
'users' => [
'driver' => 'upbond',
],
],
Once that has been added, add the guard to the middleware of any API route and check authentication during the request:
// get user
auth('upbond')->user();
// check if logged in
auth('upbond')->check();
// protect routes via middleware use
Route::group(['middleware' => 'auth:upbond'], function () {});
Route::get( '/auth/callback', '\Upbond\Auth\Login\AuthController@callback' )->name( 'auth-callback' );
UPBOND_API_URI
UPBOND_AUTH_DOMAIN
UPBOND_AUTH_CLIENT_ID
UPBOND_AUTH_CLIENT_SECRET
Install this plugin into a new or existing project using Composer:
$ composer require upbond/laravel-auth
Additional steps to install can be found in the quickstart.
We appreciate feedback and contribution to this repo! Before you get started, please see the following:
Include information on how to get support. Consider adding:
Auth helps you to easily:
The Auth Laravel Login plugin is licensed under MIT - LICENSE