-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish putting permissions on the API
- Loading branch information
1 parent
d644a53
commit 11c4f3f
Showing
14 changed files
with
434 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/Http/Requests/API/Admin/Allocations/DeleteAllocationRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Pterodactyl\Http\Requests\API\Admin\Allocations; | ||
|
||
use Pterodactyl\Models\Node; | ||
use Pterodactyl\Models\Allocation; | ||
use Pterodactyl\Services\Acl\Api\AdminAcl; | ||
use Pterodactyl\Http\Requests\API\Admin\ApiAdminRequest; | ||
|
||
class DeleteAllocationRequest extends ApiAdminRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $permission = AdminAcl::WRITE; | ||
|
||
/** | ||
* Determine if the requested allocation exists and belongs to the node that | ||
* is being passed in the URL. | ||
* | ||
* @return bool | ||
*/ | ||
public function resourceExists(): bool | ||
{ | ||
$node = $this->route()->parameter('node'); | ||
$allocation = $this->route()->parameter('allocation'); | ||
|
||
if ($node instanceof Node && $node->exists) { | ||
if ($allocation instanceof Allocation && $allocation->exists && $allocation->node_id === $node->id) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/Http/Requests/API/Admin/Allocations/GetAllocationsRequest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Pterodactyl\Http\Requests\API\Admin\Allocations; | ||
|
||
use Pterodactyl\Models\Node; | ||
use Pterodactyl\Services\Acl\Api\AdminAcl; | ||
use Pterodactyl\Http\Requests\API\Admin\ApiAdminRequest; | ||
|
||
class GetAllocationsRequest extends ApiAdminRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $resource = AdminAcl::RESOURCE_ALLOCATIONS; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $permission = AdminAcl::READ; | ||
|
||
/** | ||
* Determine if the node that we are requesting the allocations | ||
* for exists on the Panel. | ||
* | ||
* @return bool | ||
*/ | ||
public function resourceExists(): bool | ||
{ | ||
$node = $this->route()->parameter('node'); | ||
|
||
return $node instanceof Node && $node->exists; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Pterodactyl\Http\Requests\API\Admin\Nodes; | ||
|
||
use Pterodactyl\Models\Node; | ||
use Pterodactyl\Services\Acl\Api\AdminAcl; | ||
use Pterodactyl\Http\Requests\API\Admin\ApiAdminRequest; | ||
|
||
class DeleteNodeRequest extends ApiAdminRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $resource = AdminAcl::RESOURCE_NODES; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $permission = AdminAcl::WRITE; | ||
|
||
/** | ||
* Determine if the node being requested for editing exists | ||
* on the Panel before validating the data. | ||
* | ||
* @return bool | ||
*/ | ||
public function resourceExists(): bool | ||
{ | ||
$node = $this->route()->parameter('node'); | ||
|
||
return $node instanceof Node && $node->exists; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Pterodactyl\Http\Requests\API\Admin\Nodes; | ||
|
||
use Pterodactyl\Models\Node; | ||
use Pterodactyl\Http\Requests\API\Admin\ApiAdminRequest; | ||
|
||
class GetNodeRequest extends ApiAdminRequest | ||
{ | ||
/** | ||
* Determine if the requested node exists on the Panel. | ||
* | ||
* @return bool | ||
*/ | ||
public function resourceExists(): bool | ||
{ | ||
$node = $this->route()->parameter('node'); | ||
|
||
return $node instanceof Node && $node->exists; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Pterodactyl\Http\Requests\API\Admin\Nodes; | ||
|
||
use Pterodactyl\Services\Acl\Api\AdminAcl; | ||
use Pterodactyl\Http\Requests\API\Admin\ApiAdminRequest; | ||
|
||
class GetNodesRequest extends ApiAdminRequest | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected $resource = AdminAcl::RESOURCE_NODES; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $permission = AdminAcl::READ; | ||
} |
Oops, something went wrong.