mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 10:06:51 +01:00 
			
		
		
		
	* Not found property rule * Make these “better” * Day 1 * Day 2 * Day 3 * Dat 4 * Remove disabled check * Day 4 continued * Run pint * Final changes hopefully * Pint fixes * Fix again * Reset these * Update app/Filament/Admin/Pages/Health.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> * Update app/Traits/CheckMigrationsTrait.php Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com> --------- Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>
		
			
				
	
	
		
			40 lines
		
	
	
		
			928 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			928 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Services\Acl\Api;
 | 
						|
 | 
						|
use App\Models\ApiKey;
 | 
						|
 | 
						|
class AdminAcl
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * The different types of permissions available for API keys. This
 | 
						|
     * implements a read/write/none permissions scheme for all endpoints.
 | 
						|
     */
 | 
						|
    public const NONE = 0;
 | 
						|
 | 
						|
    public const READ = 1;
 | 
						|
 | 
						|
    public const WRITE = 2;
 | 
						|
 | 
						|
    /**
 | 
						|
     * Determine if an API key has permission to perform a specific read/write operation.
 | 
						|
     */
 | 
						|
    public static function can(int $permission, int $action = self::READ): bool
 | 
						|
    {
 | 
						|
        if ($permission & $action) {
 | 
						|
            return true;
 | 
						|
        }
 | 
						|
 | 
						|
        return false;
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Determine if an API Key model has permission to access a given resource
 | 
						|
     * at a specific action level.
 | 
						|
     */
 | 
						|
    public static function check(ApiKey $key, string $resource, int $action = self::READ): bool
 | 
						|
    {
 | 
						|
        return self::can($key->getPermission($resource), $action);
 | 
						|
    }
 | 
						|
}
 |