1. Go to this page and download the library: Download m7/iam 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/ */
m7 / iam example snippets
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
use Authenticatable;
protected $fillable = ['iam_uid', 'name', 'surname', 'email', 'password'];
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use m7\Iam\Traits\Iam;
class User extends Authenticatable
{
use Authenticatable, Iam;
protected $fillable = ['iam_uid', 'name', 'surname', 'email', 'password'];
}
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use m7\Iam\Http\Middleware\IamScopes;
class Kernel extends HttpKernel
{
...
protected $routeMiddleware = [
...
'iam.scopes' => IamScopes::class,
...
];
...
}
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use m7\Iam\Http\Middleware\IamAuth;
class Kernel extends HttpKernel
{
...
protected $routeMiddleware = [
...
'iam.auth' => IamAuth::class,
...
];
...
}
Auth::user()->getScopes() // get all scopes assigned to this user
Auth::user()->hasScope($scope) // check if user has certain scope ($scope can also be array, that way you can check if user has multiple scopes)