Skip to content

Commit b3a57bd

Browse files
committed
fix includes for client API keys on admin accounts; closes pterodactyl#4164
1 parent 82d8713 commit b3a57bd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/Transformers/Api/Application/BaseTransformer.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,20 @@ public static function fromRequest(Request $request)
6767
*/
6868
protected function authorize(string $resource): bool
6969
{
70+
$allowed = [ApiKey::TYPE_ACCOUNT, ApiKey::TYPE_APPLICATION];
71+
7072
$token = $this->request->user()->currentAccessToken();
71-
if (!$token instanceof ApiKey || $token->key_type !== ApiKey::TYPE_APPLICATION) {
73+
if (!$token instanceof ApiKey || !in_array($token->key_type, $allowed)) {
7274
return false;
7375
}
7476

77+
// If this is not a deprecated application token type we can only check that
78+
// the user is a root admin at the moment. In a future release we'll be rolling
79+
// out more specific permissions for keys.
80+
if ($token->key_type === ApiKey::TYPE_ACCOUNT) {
81+
return $this->request->user()->root_admin;
82+
}
83+
7584
return AdminAcl::check($token, $resource, AdminAcl::READ);
7685
}
7786

0 commit comments

Comments
 (0)