2015-12-06 13:58:49 -05:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2015-12-06 13:58:49 -05:00
|
|
|
namespace Pterodactyl\Providers;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
2022-05-22 14:57:06 -04:00
|
|
|
use Laravel\Sanctum\Sanctum;
|
|
|
|
|
use Pterodactyl\Models\ApiKey;
|
2022-06-26 16:21:07 -04:00
|
|
|
use Pterodactyl\Models\Server;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Models\User;
|
2022-05-22 14:57:06 -04:00
|
|
|
use Pterodactyl\Policies\ServerPolicy;
|
2015-12-06 13:58:49 -05:00
|
|
|
|
|
|
|
|
class AuthServiceProvider extends ServiceProvider
|
|
|
|
|
{
|
|
|
|
|
/**
|
2022-10-14 10:59:20 -06:00
|
|
|
* The model to policy mappings for the application.
|
2015-12-06 13:58:49 -05:00
|
|
|
*/
|
|
|
|
|
protected $policies = [
|
2022-05-22 14:57:06 -04:00
|
|
|
Server::class => ServerPolicy::class,
|
2015-12-06 13:58:49 -05:00
|
|
|
];
|
|
|
|
|
|
2023-02-23 12:30:16 -07:00
|
|
|
public function boot(): void
|
2015-12-06 13:58:49 -05:00
|
|
|
{
|
2022-05-22 14:57:06 -04:00
|
|
|
Sanctum::usePersonalAccessTokenModel(ApiKey::class);
|
2026-10-05 18:10:18 -04:00
|
|
|
|
|
|
|
|
// Root administrators implicitly hold every ability, including all admin API permissions.
|
|
|
|
|
Gate::before(fn (User $user): ?true => $user->root_admin ? true : null);
|
2015-12-06 13:58:49 -05:00
|
|
|
}
|
|
|
|
|
}
|