You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.7 KiB
54 lines
1.7 KiB
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
// use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
use Laravel\Passport\Passport;
|
|
use App\Models\Passport\AuthCode;
|
|
use App\Models\Passport\Client;
|
|
use App\Models\Passport\Permission;
|
|
use App\Models\Passport\PersonalAccessClient;
|
|
use App\Models\Passport\Token;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* The model to policy mappings for the application.
|
|
*
|
|
* @var array<class-string, class-string>
|
|
*/
|
|
protected $policies = [
|
|
// 'App\Models\Model' => 'App\Policies\ModelPolicy',
|
|
];
|
|
|
|
/**
|
|
* Register any authentication / authorization services.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function boot()
|
|
{
|
|
$this->registerPolicies();
|
|
|
|
// Passport::routes();
|
|
// Passport::hashClientSecrets();
|
|
Passport::tokensExpireIn(now()->addDays(15));
|
|
Passport::refreshTokensExpireIn(now()->addMonths(12));
|
|
Passport::personalAccessTokensExpireIn(now()->addMonths(6));
|
|
|
|
Passport::useTokenModel(Token::class);
|
|
Passport::useClientModel(Client::class);
|
|
Passport::useAuthCodeModel(AuthCode::class);
|
|
Passport::usePersonalAccessClientModel(PersonalAccessClient::class);
|
|
|
|
// Implicitly grant "Super Admin" role all permissions
|
|
// This works in the app by using gate-related functions like auth()->user->can() and @can()
|
|
Gate::before(function ($user, $ability) {
|
|
return $user->hasRole('Super Admin') ? true : null;
|
|
});
|
|
}
|
|
}
|
|
|