1. Go to this page and download the library: Download nanicas/auth library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace App\Models;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
protected $fillable = [
'id', // It is necessary because Auth API returns this attribute
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Nanicas\Auth\Helpers\LaravelAuthHelper;
Route::middleware([
'contract_domain.nanicas',
'auth_oauth.nanicas',
'acl.nanicas'
])->group(function () {
Route::get('/test', function (Request $request) {
Gate::authorize('create'); // This will throw an exception if the user does not have the 'create' permission
// Others routes ...
});
});
use Nanicas\Auth\Services\ThirdPartyAuthenticationService as ThirdPartyAuthenticationServiceNanicas;
use Nanicas\Auth\Services\ThirdPartyAuthorizationService as ThirdPartyAuthorizationServiceNanicas;
use Nanicas\Auth\Contracts\AuthenticationClient;
use Nanicas\Auth\Contracts\AuthorizationClient;
class YourCustomAuthentication
extends ThirdPartyAuthenticationServiceNanicas
implements AuthenticationClient
{
// ...
}
class YourCustomAuthorization
extends ThirdPartyAuthenticationServiceNanicas
implements AuthorizationClient
{
// ...
}