Skip to content

Commit a1da8a3

Browse files
committed
Merge branch 'develop' into feature/api-v1
2 parents fb7d8a9 + f9df463 commit a1da8a3

File tree

68 files changed

+1785
-524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1785
-524
lines changed

.env.travis

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ MAIL_DRIVER=array
1616
QUEUE_DRIVER=sync
1717

1818
HASHIDS_SALT=test123
19+
APP_ENVIRONMENT_ONLY=true

.php_cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ return PhpCsFixer\Config::create()
5151
'equal' => false,
5252
'identical' => false,
5353
'less_and_greater' => false,
54-
]
54+
],
5555
])->setRiskyAllowed(true)->setFinder($finder);

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
language: php
22
dist: trusty
33
php:
4-
- '7.0'
5-
- '7.1'
6-
# - '7.2'
4+
- 7.0
5+
- 7.1
6+
- 7.2
7+
matrix:
8+
fast_finish: true
9+
allow_failures:
10+
- php: 7.2
711
sudo: false
812
cache:
913
directories:

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1010
* `[beta.2]` — Fixes a bug that would throw a red page of death when submitting an invalid egg variable value for a server in the Admin CP.
1111
* `[beta.2]` — Someone found a `@todo` that I never `@todid` and thus database hosts could not be created without being linked to a node. This is fixed...
1212
* `[beta.2]` — Fixes bug that caused incorrect rendering of CPU usage on server graphs due to missing variable.
13+
* `[beta.2]` — Fixes bug causing schedules to be un-deletable.
14+
* `[beta.2]` — Fixes bug that prevented the deletion of nodes due to an allocation deletion cascade issue with the SQL schema.
15+
16+
### Changed
17+
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
18+
19+
### Added
20+
* Added star indicators to user listing in Admin CP to indicate users who are set as a root admin.
21+
22+
### Changed
23+
* API keys have been changed to only use a single public key passed in a bearer token. All existing keys can continue being used, however only the first 32 characters should be sent.
1324

1425
### Changed
1526
* API keys have been changed to only use a single public key passed in a bearer token. All existing keys can continue being used, however only the first 32 characters should be sent.

app/Contracts/Repository/Daemon/ServerRepositoryInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ public function details();
7878
/**
7979
* Revoke an access key on the daemon before the time is expired.
8080
*
81-
* @param string $key
81+
* @param string|array $key
8282
* @return \Psr\Http\Message\ResponseInterface
83+
*
84+
* @throws \GuzzleHttp\Exception\RequestException
8385
*/
8486
public function revokeAccessKey($key);
8587
}

app/Contracts/Repository/DaemonKeyRepositoryInterface.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424

2525
namespace Pterodactyl\Contracts\Repository;
2626

27+
use Pterodactyl\Models\User;
2728
use Pterodactyl\Models\DaemonKey;
29+
use Illuminate\Support\Collection;
2830

2931
interface DaemonKeyRepositoryInterface extends RepositoryInterface
3032
{
@@ -59,4 +61,22 @@ public function getServerKeys($server);
5961
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
6062
*/
6163
public function getKeyWithServer($key);
64+
65+
/**
66+
* Get all of the keys for a specific user including the information needed
67+
* from their server relation for revocation on the daemon.
68+
*
69+
* @param \Pterodactyl\Models\User $user
70+
* @return \Illuminate\Support\Collection
71+
*/
72+
public function getKeysForRevocation(User $user): Collection;
73+
74+
/**
75+
* Delete an array of daemon keys from the database. Used primarily in
76+
* conjunction with getKeysForRevocation.
77+
*
78+
* @param array $ids
79+
* @return bool|int
80+
*/
81+
public function deleteKeys(array $ids);
6282
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Pterodactyl\Contracts\Repository;
4+
5+
interface SettingsRepositoryInterface extends RepositoryInterface
6+
{
7+
/**
8+
* Store a new persistent setting in the database.
9+
*
10+
* @param string $key
11+
* @param string $value
12+
* @return mixed
13+
*/
14+
public function set(string $key, string $value);
15+
16+
/**
17+
* Retrieve a persistent setting from the database.
18+
*
19+
* @param string $key
20+
* @param mixed $default
21+
* @return mixed
22+
*/
23+
public function get(string $key, $default);
24+
25+
/**
26+
* Remove a key from the database cache.
27+
*
28+
* @param string $key
29+
* @return mixed
30+
*/
31+
public function forget(string $key);
32+
}

app/Exceptions/Http/Connection/DaemonConnectionException.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Exceptions\Http\Connection;
114

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,25 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Http\Controllers\Admin;
114

12-
use Krucas\Settings\Settings;
13-
use Prologue\Alerts\AlertsMessageBag;
5+
use Illuminate\View\View;
146
use Pterodactyl\Http\Controllers\Controller;
15-
use Pterodactyl\Http\Requests\Admin\BaseFormRequest;
167
use Pterodactyl\Services\Helpers\SoftwareVersionService;
178

189
class BaseController extends Controller
1910
{
20-
/**
21-
* @var \Prologue\Alerts\AlertsMessageBag
22-
*/
23-
protected $alert;
24-
25-
/**
26-
* @var \Krucas\Settings\Settings
27-
*/
28-
protected $settings;
29-
3011
/**
3112
* @var \Pterodactyl\Services\Helpers\SoftwareVersionService
3213
*/
33-
protected $version;
14+
private $version;
3415

3516
/**
3617
* BaseController constructor.
3718
*
38-
* @param \Prologue\Alerts\AlertsMessageBag $alert
39-
* @param \Krucas\Settings\Settings $settings
4019
* @param \Pterodactyl\Services\Helpers\SoftwareVersionService $version
4120
*/
42-
public function __construct(
43-
AlertsMessageBag $alert,
44-
Settings $settings,
45-
SoftwareVersionService $version
46-
) {
47-
$this->alert = $alert;
48-
$this->settings = $settings;
21+
public function __construct(SoftwareVersionService $version)
22+
{
4923
$this->version = $version;
5024
}
5125

@@ -54,34 +28,8 @@ public function __construct(
5428
*
5529
* @return \Illuminate\View\View
5630
*/
57-
public function getIndex()
31+
public function index(): View
5832
{
5933
return view('admin.index', ['version' => $this->version]);
6034
}
61-
62-
/**
63-
* Return the admin settings view.
64-
*
65-
* @return \Illuminate\View\View
66-
*/
67-
public function getSettings()
68-
{
69-
return view('admin.settings');
70-
}
71-
72-
/**
73-
* Handle settings post request.
74-
*
75-
* @param \Pterodactyl\Http\Requests\Admin\BaseFormRequest $request
76-
* @return \Illuminate\Http\RedirectResponse
77-
*/
78-
public function postSettings(BaseFormRequest $request)
79-
{
80-
$this->settings->set('company', $request->input('company'));
81-
$this->settings->set('2fa', $request->input('2fa'));
82-
83-
$this->alert->success('Settings have been successfully updated.')->flash();
84-
85-
return redirect()->route('admin.settings');
86-
}
8735
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
namespace Pterodactyl\Http\Controllers\Admin\Settings;
4+
5+
use Illuminate\View\View;
6+
use Illuminate\Http\RedirectResponse;
7+
use Prologue\Alerts\AlertsMessageBag;
8+
use Illuminate\Contracts\Console\Kernel;
9+
use Pterodactyl\Http\Controllers\Controller;
10+
use Illuminate\Contracts\Config\Repository as ConfigRepository;
11+
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
12+
use Pterodactyl\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest;
13+
14+
class AdvancedController extends Controller
15+
{
16+
/**
17+
* @var \Prologue\Alerts\AlertsMessageBag
18+
*/
19+
private $alert;
20+
21+
/**
22+
* @var \Illuminate\Contracts\Config\Repository
23+
*/
24+
private $config;
25+
26+
/**
27+
* @var \Illuminate\Contracts\Console\Kernel
28+
*/
29+
private $kernel;
30+
31+
/**
32+
* @var \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface
33+
*/
34+
private $settings;
35+
36+
/**
37+
* AdvancedController constructor.
38+
*
39+
* @param \Prologue\Alerts\AlertsMessageBag $alert
40+
* @param \Illuminate\Contracts\Config\Repository $config
41+
* @param \Illuminate\Contracts\Console\Kernel $kernel
42+
* @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings
43+
*/
44+
public function __construct(
45+
AlertsMessageBag $alert,
46+
ConfigRepository $config,
47+
Kernel $kernel,
48+
SettingsRepositoryInterface $settings
49+
) {
50+
$this->alert = $alert;
51+
$this->config = $config;
52+
$this->kernel = $kernel;
53+
$this->settings = $settings;
54+
}
55+
56+
/**
57+
* Render advanced Panel settings UI.
58+
*
59+
* @return \Illuminate\View\View
60+
*/
61+
public function index(): View
62+
{
63+
$showRecaptchaWarning = false;
64+
if (
65+
$this->config->get('recaptcha._shipped_secret_key') === $this->config->get('recaptcha.secret_key')
66+
|| $this->config->get('recaptcha._shipped_website_key') === $this->config->get('recaptcha.website_key')
67+
) {
68+
$showRecaptchaWarning = true;
69+
}
70+
71+
return view('admin.settings.advanced', [
72+
'showRecaptchaWarning' => $showRecaptchaWarning,
73+
]);
74+
}
75+
76+
/**
77+
* @param \Pterodactyl\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest $request
78+
* @return \Illuminate\Http\RedirectResponse
79+
*/
80+
public function update(AdvancedSettingsFormRequest $request): RedirectResponse
81+
{
82+
foreach ($request->normalize() as $key => $value) {
83+
$this->settings->set('settings::' . $key, $value);
84+
}
85+
86+
$this->kernel->call('queue:restart');
87+
$this->alert->success('Advanced settings have been updated successfully and the queue worker was restarted to apply these changes.')->flash();
88+
89+
return redirect()->route('admin.settings.advanced');
90+
}
91+
}

0 commit comments

Comments
 (0)