Skip to content

Commit 468d426

Browse files
committed
Limit to 5 API keys at a time.
Ref advisory #GHSA-pjmh-7xfm-r4x9
1 parent 8eba1da commit 468d426

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
55

66
## v0.7.17 (Derelict Dermodactylus)
77
### Fixed
8+
* Limited accounts to 5 API keys at a time.
89
* Fixes database passwords not being generated with the proper requirements for some MySQL setups.
910
* Hostnames that are not FQDNs/IP addresses can now be used for connecting to a MySQL host.
1011

app/Http/Controllers/Base/AccountKeyController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Http\Response;
88
use Pterodactyl\Models\ApiKey;
99
use Prologue\Alerts\AlertsMessageBag;
10+
use Pterodactyl\Exceptions\DisplayException;
1011
use Pterodactyl\Http\Controllers\Controller;
1112
use Pterodactyl\Services\Api\KeyCreationService;
1213
use Pterodactyl\Http\Requests\Base\StoreAccountKeyRequest;
@@ -76,10 +77,17 @@ public function create(Request $request): View
7677
* @param \Pterodactyl\Http\Requests\Base\StoreAccountKeyRequest $request
7778
* @return \Illuminate\Http\RedirectResponse
7879
*
80+
* @throws \Pterodactyl\Exceptions\DisplayException
7981
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
8082
*/
8183
public function store(StoreAccountKeyRequest $request)
8284
{
85+
if ($this->repository->findCountWhere(['user_id' => $request->user()->id]) >= 5) {
86+
throw new DisplayException(
87+
'Cannot assign more than 5 API keys to an account.'
88+
);
89+
}
90+
8391
$this->keyService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([
8492
'user_id' => $request->user()->id,
8593
'allowed_ips' => $request->input('allowed_ips'),

0 commit comments

Comments
 (0)