Merge branch 'feature/laravel-55-update' into feature/api-v1

This commit is contained in:
Dane Everitt 2017-12-16 17:19:35 -06:00
commit f30f4b45ba
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
35 changed files with 1024 additions and 822 deletions

View file

@ -4,10 +4,6 @@ php:
- 7.0
- 7.1
- 7.2
matrix:
fast_finish: true
allow_failures:
- php: 7.2
sudo: false
cache:
directories:

View file

@ -13,14 +13,15 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* `[beta.2]` — Fixes bug causing schedules to be un-deletable.
* `[beta.2]` — Fixes bug that prevented the deletion of nodes due to an allocation deletion cascade issue with the SQL schema.
### Changed
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
* Updated core framework to Laravel 5.5. This includes many dependency updates.
* Certain AWS specific environment keys were changed, this should have minimal impact on users unless you specifically enabled AWS specific features. The renames are: `AWS_KEY -> AWS_ACCESS_KEY_ID`, `AWS_SECRET -> AWS_SECRET_ACCESS_KEY`, `AWS_REGION -> AWS_DEFAULT_REGION`
### Added
* Added star indicators to user listing in Admin CP to indicate users who are set as a root admin.
* Settings are now editable via the Admin CP and override config values where possible.
### Changed
* Revoking the administrative status for an admin will revoke all authentication tokens currently assigned to their account.
* 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.
## v0.7.0-beta.2 (Derelict Dermodactylus)
### Fixed
* `[beta.1]` — Fixes a CORS header issue due to a wrong API endpoint being provided in the administrative node listing.

View file

@ -1,14 +1,8 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Console\Commands\Maintenance;
use SplFileInfo;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
@ -17,11 +11,6 @@ class CleanServiceBackupFilesCommand extends Command
{
const BACKUP_THRESHOLD_MINUTES = 5;
/**
* @var \Carbon\Carbon
*/
protected $carbon;
/**
* @var string
*/
@ -40,14 +29,12 @@ class CleanServiceBackupFilesCommand extends Command
/**
* CleanServiceBackupFilesCommand constructor.
*
* @param \Carbon\Carbon $carbon
* @param \Illuminate\Contracts\Filesystem\Factory $filesystem
*/
public function __construct(Carbon $carbon, FilesystemFactory $filesystem)
public function __construct(FilesystemFactory $filesystem)
{
parent::__construct();
$this->carbon = $carbon;
$this->disk = $filesystem->disk();
}
@ -58,11 +45,11 @@ class CleanServiceBackupFilesCommand extends Command
{
$files = $this->disk->files('services/.bak');
collect($files)->each(function ($file) {
$lastModified = $this->carbon->timestamp($this->disk->lastModified($file));
if ($lastModified->diffInMinutes($this->carbon->now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file);
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file]));
collect($files)->each(function (SplFileInfo $file) {
$lastModified = Carbon::createFromTimestamp($this->disk->lastModified($file->getPath()));
if ($lastModified->diffInMinutes(Carbon::now()) > self::BACKUP_THRESHOLD_MINUTES) {
$this->disk->delete($file->getPath());
$this->info(trans('command/messages.maintenance.deleting_service_backup', ['file' => $file->getFilename()]));
}
});
}

View file

@ -3,41 +3,17 @@
namespace Pterodactyl\Console;
use Illuminate\Console\Scheduling\Schedule;
use Pterodactyl\Console\Commands\InfoCommand;
use Pterodactyl\Console\Commands\User\MakeUserCommand;
use Pterodactyl\Console\Commands\User\DeleteUserCommand;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Pterodactyl\Console\Commands\Server\RebuildServerCommand;
use Pterodactyl\Console\Commands\Location\MakeLocationCommand;
use Pterodactyl\Console\Commands\User\DisableTwoFactorCommand;
use Pterodactyl\Console\Commands\Environment\AppSettingsCommand;
use Pterodactyl\Console\Commands\Location\DeleteLocationCommand;
use Pterodactyl\Console\Commands\Schedule\ProcessRunnableCommand;
use Pterodactyl\Console\Commands\Environment\EmailSettingsCommand;
use Pterodactyl\Console\Commands\Environment\DatabaseSettingsCommand;
use Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
* Register the commands for the application.
*/
protected $commands = [
AppSettingsCommand::class,
CleanServiceBackupFilesCommand::class,
DatabaseSettingsCommand::class,
DeleteLocationCommand::class,
DeleteUserCommand::class,
DisableTwoFactorCommand::class,
EmailSettingsCommand::class,
InfoCommand::class,
MakeLocationCommand::class,
MakeUserCommand::class,
ProcessRunnableCommand::class,
RebuildServerCommand::class,
];
protected function commands()
{
$this->load(__DIR__ . '/Commands');
}
/**
* Define the application's command schedule.

View file

@ -163,7 +163,7 @@ class PackController extends Controller
*/
public function store(PackFormRequest $request)
{
if ($request->has('from_template')) {
if ($request->filled('from_template')) {
$pack = $this->templateUploadService->handle($request->input('egg_id'), $request->file('file_upload'));
} else {
$pack = $this->creationService->handle($request->normalize(), $request->file('file_upload'));

View file

@ -524,7 +524,7 @@ class ServersController extends Controller
*/
public function delete(Request $request, Server $server)
{
$this->deletionService->withForce($request->has('force_delete'))->handle($server);
$this->deletionService->withForce($request->filled('force_delete'))->handle($server);
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
return redirect()->route('admin.servers');

View file

@ -107,6 +107,8 @@ class LoginController extends Controller
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response
*
* @throws \Illuminate\Validation\ValidationException
*/
public function login(Request $request)
{
@ -115,8 +117,7 @@ class LoginController extends Controller
if ($this->hasTooManyLoginAttempts($request)) {
$this->fireLockoutEvent($request);
return $this->sendLockoutResponse($request);
$this->sendLockoutResponse($request);
}
try {

View file

@ -1,27 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>
* Some Modifications (c) 2015 Dylan Seidt <dylan.seidt@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Http\Controllers\Base;

View file

@ -2,10 +2,10 @@
namespace Pterodactyl\Http;
use Fideloper\Proxy\TrustProxies;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\Authenticate;
use Pterodactyl\Http\Middleware\TrimStrings;
use Pterodactyl\Http\Middleware\TrustProxies;
use Illuminate\Session\Middleware\StartSession;
use Pterodactyl\Http\Middleware\EncryptCookies;
use Pterodactyl\Http\Middleware\VerifyCsrfToken;
@ -23,6 +23,7 @@ use Pterodactyl\Http\Middleware\RedirectIfAuthenticated;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Pterodactyl\Http\Middleware\API\AuthenticateIPAccess;
use Pterodactyl\Http\Middleware\Daemon\DaemonAuthenticate;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Pterodactyl\Http\Middleware\API\HasPermissionToResource;
use Pterodactyl\Http\Middleware\Server\AuthenticateAsSubuser;
@ -31,6 +32,7 @@ use Pterodactyl\Http\Middleware\RequireTwoFactorAuthentication;
use Pterodactyl\Http\Middleware\Server\DatabaseBelongsToServer;
use Pterodactyl\Http\Middleware\Server\ScheduleBelongsToServer;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode;
use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
use Pterodactyl\Http\Middleware\DaemonAuthenticate as OldDaemonAuthenticate;
class Kernel extends HttpKernel
@ -42,9 +44,9 @@ class Kernel extends HttpKernel
*/
protected $middleware = [
CheckForMaintenanceMode::class,
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
ValidatePostSize::class,
TrimStrings::class,
ConvertEmptyStringsToNull::class,
TrustProxies::class,
];

View file

@ -0,0 +1,29 @@
<?php
namespace Pterodactyl\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
class TrustProxies extends Middleware
{
/**
* The trusted proxies for this application.
*
* @var array
*/
protected $proxies;
/**
* The current proxy header mappings.
*
* @var array
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
}

View file

@ -39,7 +39,7 @@ class VerifyReCaptcha
return $next($request);
}
if ($request->has('g-recaptcha-response')) {
if ($request->filled('g-recaptcha-response')) {
$client = new Client();
$res = $client->post($this->config->get('recaptcha.domain'), [
'form_params' => [

View file

@ -44,9 +44,6 @@ abstract class AdminFormRequest extends FormRequest
*/
public function normalize($only = [])
{
return array_merge(
$this->only($only),
$this->intersect(array_keys($this->rules()))
);
return $this->all(empty($only) ? array_keys($this->rules()) : $only);
}
}

View file

@ -18,7 +18,7 @@ class DatabaseHostFormRequest extends AdminFormRequest
*/
public function rules()
{
if (! $this->has('node_id')) {
if (! $this->filled('node_id')) {
$this->merge(['node_id' => null]);
}

View file

@ -1,11 +1,4 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin;
@ -33,7 +26,7 @@ class UserFormRequest extends AdminFormRequest
{
if ($this->method === 'PATCH') {
return array_merge(
$this->intersect('password'),
$this->all(['password']),
$this->only(['email', 'username', 'name_first', 'name_last', 'root_admin', 'ignore_connection_error'])
);
}

View file

@ -9,8 +9,6 @@
namespace Pterodactyl\Models;
use File;
use Storage;
use Sofa\Eloquence\Eloquence;
use Sofa\Eloquence\Validable;
use Illuminate\Database\Eloquent\Model;
@ -88,30 +86,6 @@ class Pack extends Model implements CleansAttributes, ValidableContract
'version' => 2,
];
/**
* Returns all of the archived files for a given pack.
*
* @param bool $collection
* @return \Illuminate\Support\Collection|object
* @deprecated
*/
public function files($collection = false)
{
$files = collect(Storage::files('packs/' . $this->uuid));
$files = $files->map(function ($item) {
$path = storage_path('app/' . $item);
return (object) [
'name' => basename($item),
'hash' => sha1_file($path),
'size' => File::humanReadableSize($path),
];
});
return ($collection) ? $files : (object) $files->all();
}
/**
* Gets egg associated with a service pack.
*

View file

@ -51,4 +51,17 @@ class ServerPolicy
return $this->checkPermission($user, $server, $ability);
}
/**
* This is a horrendous hack to avoid Laravel's "smart" behavior that does
* not call the before() function if there isn't a function matching the
* policy permission.
*
* @param string $name
* @param mixed $arguments
*/
public function __call($name, $arguments)
{
// do nothing
}
}

View file

@ -12,8 +12,6 @@ use Illuminate\Support\ServiceProvider;
use Pterodactyl\Observers\UserObserver;
use Pterodactyl\Observers\ServerObserver;
use Pterodactyl\Observers\SubuserObserver;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Barryvdh\Debugbar\ServiceProvider as DebugbarServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@ -32,17 +30,6 @@ class AppServiceProvider extends ServiceProvider
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
}
/**
* Register any application services.
*/
public function register()
{
if ($this->app->environment() !== 'production') {
$this->app->register(DebugbarServiceProvider::class);
$this->app->register(IdeHelperServiceProvider::class);
}
}
/**
* Return version information for the footer.
*

View file

@ -12,12 +12,4 @@ class EventServiceProvider extends ServiceProvider
* @var array
*/
protected $listen = [];
/**
* Register any other events for your application.
*/
public function boot()
{
parent::boot();
}
}

View file

@ -87,6 +87,24 @@ class SettingsServiceProvider extends ServiceProvider
}
}
switch (strtolower($value)) {
case 'true':
case '(true)':
$value = true;
break;
case 'false':
case '(false)':
$value = false;
break;
case 'empty':
case '(empty)':
$value = '';
break;
case 'null':
case '(null)':
$value = null;
}
$config->set(str_replace(':', '.', $key), $value);
}
}

View file

@ -15,43 +15,40 @@
"ext-mbstring": "*",
"ext-pdo_mysql": "*",
"ext-zip": "*",
"appstract/laravel-blade-directives": "^0.6.0",
"aws/aws-sdk-php": "^3.29",
"daneeveritt/login-notifications": "^1.0",
"appstract/laravel-blade-directives": "^0.7",
"aws/aws-sdk-php": "^3.48",
"doctrine/dbal": "^2.5",
"edvinaskrucas/settings": "^2.0",
"fideloper/proxy": "^3.3",
"guzzlehttp/guzzle": "~6.3.0",
"guzzlehttp/guzzle": "^6.3",
"hashids/hashids": "^2.0",
"igaster/laravel-theme": "^1.16",
"laracasts/utilities": "^3.0",
"laravel/framework": "5.4.27",
"laravel/tinker": "1.0.1",
"lord/laroute": "~2.4.5",
"laravel/framework": "5.5.*",
"laravel/tinker": "^1.0",
"lord/laroute": "^2.4",
"matriphe/iso-639": "^1.2",
"mtdowling/cron-expression": "^1.2",
"nesbot/carbon": "^1.22",
"nicolaslopezj/searchable": "^1.9",
"pragmarx/google2fa": "^2.0",
"predis/predis": "^1.1",
"prologue/alerts": "^0.4",
"ramsey/uuid": "^3.7",
"s1lentium/iptools": "^1.1",
"sofa/eloquence": "~5.4.1",
"spatie/laravel-fractal": "^4.0",
"watson/validating": "^3.0",
"sofa/eloquence-base": "v5.5",
"sofa/eloquence-validable": "v5.5",
"spatie/laravel-fractal": "^5.3",
"webmozart/assert": "^1.2",
"webpatser/laravel-uuid": "^2.0",
"znck/belongs-to-through": "^2.3"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^2.4",
"barryvdh/laravel-debugbar": "^3.1",
"barryvdh/laravel-ide-helper": "^2.4",
"filp/whoops": "^2.1",
"friendsofphp/php-cs-fixer": "^2.8.0",
"fzaninotto/faker": "^1.6",
"mockery/mockery": "^0.9",
"php-mock/php-mock-phpunit": "^1.1",
"phpunit/phpunit": "^5.7"
"mockery/mockery": "^1.0",
"php-mock/php-mock-phpunit": "^2.0",
"phpunit/phpunit": "~6.4.0"
},
"autoload": {
"classmap": [
@ -70,13 +67,15 @@
}
},
"scripts": {
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"prefer-stable": true,

1331
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,15 @@
<?php
return [
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Version
|--------------------------------------------------------------------------
| This value is set when creating a Pterodactyl release. You should not
| change this value if you are not maintaining your own internal versions.
*/
'version' => env('APP_VERSION', 'canary'),
'version' => 'canary',
/*
|--------------------------------------------------------------------------
@ -15,8 +20,22 @@ return [
| framework needs to place the application's name in a notification or
| any other location as required by the application or its packages.
*/
'name' => env('APP_NAME', 'Pterodactyl'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services your application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
@ -93,7 +112,7 @@ return [
|
*/
'key' => env('APP_KEY', 'SomeRandomString3232RandomString'),
'key' => env('APP_KEY'),
'cipher' => 'AES-256-CBC',
@ -112,7 +131,7 @@ return [
'log' => env('APP_LOG', 'daily'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
'log_level' => env('APP_LOG_LEVEL', 'info'),
/*
|--------------------------------------------------------------------------
@ -141,6 +160,7 @@ return [
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
@ -149,12 +169,6 @@ return [
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
/*
* Package Service Providers...
*/
Laravel\Tinker\TinkerServiceProvider::class,
/*
* Application Service Providers...
@ -175,12 +189,7 @@ return [
*/
igaster\laravelTheme\themeServiceProvider::class,
Prologue\Alerts\AlertsServiceProvider::class,
Fideloper\Proxy\TrustedProxyServiceProvider::class,
Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class,
Lord\Laroute\LarouteServiceProvider::class,
Spatie\Fractal\FractalServiceProvider::class,
Sofa\Eloquence\ServiceProvider::class,
Appstract\BladeDirectives\BladeDirectivesServiceProvider::class,
],
/*
@ -205,17 +214,14 @@ return [
'Carbon' => Carbon\Carbon::class,
'Config' => Illuminate\Support\Facades\Config::class,
'Cookie' => Illuminate\Support\Facades\Cookie::class,
'Cron' => Cron\CronExpression::class,
'Crypt' => Illuminate\Support\Facades\Crypt::class,
'DB' => Illuminate\Support\Facades\DB::class,
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class,
'Fractal' => Spatie\Fractal\FractalFacade::class,
'Gate' => Illuminate\Support\Facades\Gate::class,
'Hash' => Illuminate\Support\Facades\Hash::class,
'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Javascript' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class,
'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class,
@ -233,7 +239,6 @@ return [
'Storage' => Illuminate\Support\Facades\Storage::class,
'Theme' => igaster\laravelTheme\Facades\Theme::class,
'URL' => Illuminate\Support\Facades\URL::class,
'Uuid' => Webpatser\Uuid\Uuid::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
],

View file

@ -10,6 +10,8 @@ return [
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file", "memcached", "redis"
|
*/
'default' => env('CACHE_DRIVER', 'file'),
@ -39,6 +41,7 @@ return [
'table' => 'cache',
'connection' => null,
],
'file' => [
'driver' => 'file',
'path' => storage_path('framework/cache/data'),
@ -80,5 +83,5 @@ return [
|
*/
'prefix' => 'pterodactyl',
'prefix' => env('CACHE_PREFIX', str_slug(env('APP_NAME', 'pterodactyl'), '_') . '_cache'),
];

View file

@ -75,7 +75,7 @@ return [
'host' => env('REDIS_HOST', 'localhost'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
'database' => env('REDIS_DATBASE', 0),
],
],
];

View file

@ -10,11 +10,9 @@ return [
| by the framework. A "local" driver, as well as a variety of cloud
| based drivers are available for your choosing. Just store away!
|
| Supported: "local", "ftp", "s3", "rackspace"
|
*/
'default' => 'local',
'default' => env('FILESYSTEM_DRIVER', 'local'),
/*
|--------------------------------------------------------------------------
@ -27,7 +25,7 @@ return [
|
*/
'cloud' => 's3',
'cloud' => env('FILESYSTEM_CLOUD', 's3'),
/*
|--------------------------------------------------------------------------
@ -56,9 +54,9 @@ return [
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
],
],

View file

@ -28,7 +28,7 @@ return [
|
*/
'lifetime' => 10080,
'lifetime' => env('SESSION_LIFETIME', 10080),
'expire_on_close' => false,
@ -121,7 +121,7 @@ return [
|
*/
'cookie' => 'pterodactyl_session',
'cookie' => env('SESSION_COOKIE', str_slug(env('APP_NAME', 'pterodactyl'), '_') . '_session'),
/*
|--------------------------------------------------------------------------
@ -174,4 +174,19 @@ return [
*/
'http_only' => true,
/*
|--------------------------------------------------------------------------
| Same-Site Cookies
|--------------------------------------------------------------------------
|
| This option determines how your cookies behave when cross-site requests
| take place, and can be used to mitigate CSRF attacks. By default, we
| do not enable this as other CSRF protection services are in place.
|
| Supported: "lax", "strict"
|
*/
'same_site' => null,
];

View file

@ -1,5 +1,7 @@
<?php
use Faker\Generator as Faker;
/*
|--------------------------------------------------------------------------
| Model Factories
@ -11,9 +13,7 @@
|
*/
\Sofa\Eloquence\Model::unsetEventDispatcher();
$factory->define(Pterodactyl\Models\Server::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Server::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'node_id' => $faker->randomNumber(),
@ -39,7 +39,7 @@ $factory->define(Pterodactyl\Models\Server::class, function (Faker\Generator $fa
];
});
$factory->define(Pterodactyl\Models\User::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\User::class, function (Faker $faker) {
static $password;
return [
@ -63,7 +63,7 @@ $factory->state(Pterodactyl\Models\User::class, 'admin', function () {
];
});
$factory->define(Pterodactyl\Models\Location::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Location::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'short' => $faker->domainWord,
@ -71,7 +71,7 @@ $factory->define(Pterodactyl\Models\Location::class, function (Faker\Generator $
];
});
$factory->define(Pterodactyl\Models\Node::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Node::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid,
@ -92,7 +92,7 @@ $factory->define(Pterodactyl\Models\Node::class, function (Faker\Generator $fake
];
});
$factory->define(Pterodactyl\Models\Nest::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Nest::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid,
@ -102,7 +102,7 @@ $factory->define(Pterodactyl\Models\Nest::class, function (Faker\Generator $fake
];
});
$factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Egg::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'uuid' => $faker->unique()->uuid,
@ -113,7 +113,7 @@ $factory->define(Pterodactyl\Models\Egg::class, function (Faker\Generator $faker
];
});
$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\EggVariable::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'name' => $faker->firstName,
@ -134,7 +134,7 @@ $factory->state(Pterodactyl\Models\EggVariable::class, 'editable', function () {
return ['user_editable' => 1];
});
$factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Pack::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'egg_id' => $faker->randomNumber(),
@ -148,7 +148,7 @@ $factory->define(Pterodactyl\Models\Pack::class, function (Faker\Generator $fake
];
});
$factory->define(Pterodactyl\Models\Subuser::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Subuser::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'user_id' => $faker->randomNumber(),
@ -156,7 +156,7 @@ $factory->define(Pterodactyl\Models\Subuser::class, function (Faker\Generator $f
];
});
$factory->define(Pterodactyl\Models\Allocation::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Allocation::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'node_id' => $faker->randomNumber(),
@ -165,7 +165,7 @@ $factory->define(Pterodactyl\Models\Allocation::class, function (Faker\Generator
];
});
$factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'name' => $faker->colorName,
@ -177,7 +177,7 @@ $factory->define(Pterodactyl\Models\DatabaseHost::class, function (Faker\Generat
];
});
$factory->define(Pterodactyl\Models\Database::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Database::class, function (Faker $faker) {
static $password;
return [
@ -192,7 +192,7 @@ $factory->define(Pterodactyl\Models\Database::class, function (Faker\Generator $
];
});
$factory->define(Pterodactyl\Models\Schedule::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Schedule::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'server_id' => $faker->randomNumber(),
@ -200,7 +200,7 @@ $factory->define(Pterodactyl\Models\Schedule::class, function (Faker\Generator $
];
});
$factory->define(Pterodactyl\Models\Task::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\Task::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'schedule_id' => $faker->randomNumber(),
@ -212,7 +212,7 @@ $factory->define(Pterodactyl\Models\Task::class, function (Faker\Generator $fake
];
});
$factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'server_id' => $faker->randomNumber(),
@ -222,7 +222,7 @@ $factory->define(Pterodactyl\Models\DaemonKey::class, function (Faker\Generator
];
});
$factory->define(Pterodactyl\Models\APIKey::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\APIKey::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'user_id' => $faker->randomNumber(),
@ -233,7 +233,7 @@ $factory->define(Pterodactyl\Models\APIKey::class, function (Faker\Generator $fa
];
});
$factory->define(Pterodactyl\Models\APIPermission::class, function (Faker\Generator $faker) {
$factory->define(Pterodactyl\Models\APIPermission::class, function (Faker $faker) {
return [
'id' => $faker->unique()->randomNumber(),
'key_id' => $faker->randomNumber(),

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"

View file

@ -1,17 +1,18 @@
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Prevent stripping authorization headers
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d

View file

@ -3,8 +3,9 @@
/**
* Laravel - A PHP Framework For Web Artisans.
*
* @author Taylor Otwell <taylorotwell@gmail.com>
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
@ -14,11 +15,11 @@
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__ . '/../bootstrap/autoload.php';
require __DIR__ . '/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------

View file

@ -113,13 +113,6 @@
<th>SHA1 Hash</th>
<th>File Size</th>
</tr>
@foreach($pack->files() as $file)
<tr>
<td>{{ $file->name }}</td>
<td><code>{{ $file->hash }}</code></td>
<td>{{ $file->size }}</td>
</tr>
@endforeach
</table>
</div>
<div class="box-footer">

View file

@ -1,14 +1,8 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Tests\Unit\Commands\Maintenance;
use SplFileInfo;
use Mockery as m;
use Carbon\Carbon;
use Tests\Unit\Commands\CommandTestCase;
@ -18,11 +12,6 @@ use Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand;
class CleanServiceBackupFilesCommandTest extends CommandTestCase
{
/**
* @var \Carbon\Carbon|\Mockery\Mock
*/
protected $carbon;
/**
* @var \Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand
*/
@ -45,13 +34,10 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
{
parent::setUp();
$this->carbon = m::mock(Carbon::class);
Carbon::setTestNow();
$this->disk = m::mock(Filesystem::class);
$this->filesystem = m::mock(Factory::class);
$this->filesystem->shouldReceive('disk')->withNoArgs()->once()->andReturn($this->disk);
$this->command = new CleanServiceBackupFilesCommand($this->carbon, $this->filesystem);
$this->command->setLaravel($this->app);
}
/**
@ -59,14 +45,13 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
*/
public function testCommandCleansFilesMoreThan5MinutesOld()
{
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn(['testfile.txt']);
$this->disk->shouldReceive('lastModified')->with('testfile.txt')->once()->andReturn('disk:last:modified');
$this->carbon->shouldReceive('timestamp')->with('disk:last:modified')->once()->andReturnSelf();
$this->carbon->shouldReceive('now')->withNoArgs()->once()->andReturnNull();
$this->carbon->shouldReceive('diffInMinutes')->with(null)->once()->andReturn(10);
$this->disk->shouldReceive('delete')->with('testfile.txt')->once()->andReturnNull();
$file = new SplFileInfo('testfile.txt');
$display = $this->runCommand($this->command);
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->subDays(100)->getTimestamp());
$this->disk->shouldReceive('delete')->with($file->getPath())->once()->andReturnNull();
$display = $this->runCommand($this->getCommand());
$this->assertNotEmpty($display);
$this->assertContains(trans('command/messages.maintenance.deleting_service_backup', ['file' => 'testfile.txt']), $display);
@ -77,14 +62,26 @@ class CleanServiceBackupFilesCommandTest extends CommandTestCase
*/
public function testCommandDoesNotCleanFileLessThan5MinutesOld()
{
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn(['testfile.txt']);
$this->disk->shouldReceive('lastModified')->with('testfile.txt')->once()->andReturn('disk:last:modified');
$this->carbon->shouldReceive('timestamp')->with('disk:last:modified')->once()->andReturnSelf();
$this->carbon->shouldReceive('now')->withNoArgs()->once()->andReturnNull();
$this->carbon->shouldReceive('diffInMinutes')->with(null)->once()->andReturn(2);
$file = new SplFileInfo('testfile.txt');
$display = $this->runCommand($this->command);
$this->disk->shouldReceive('files')->with('services/.bak')->once()->andReturn([$file]);
$this->disk->shouldReceive('lastModified')->with($file->getPath())->once()->andReturn(Carbon::now()->getTimestamp());
$display = $this->runCommand($this->getCommand());
$this->assertEmpty($display);
}
/**
* Return an instance of the command for testing.
*
* @return \Pterodactyl\Console\Commands\Maintenance\CleanServiceBackupFilesCommand
*/
private function getCommand(): CleanServiceBackupFilesCommand
{
$command = new CleanServiceBackupFilesCommand($this->filesystem);
$command->setLaravel($this->app);
return $command;
}
}

View file

@ -50,13 +50,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForPassword()
{
$this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser();
$user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('password');
$this->request->shouldReceive('input')->with('new_password')->once()->andReturn('test-password');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['password' => 'test-password'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request);
@ -70,13 +70,13 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForEmail()
{
$this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser();
$user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('email');
$this->request->shouldReceive('input')->with('new_email')->once()->andReturn('test@example.com');
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['email' => 'test@example.com'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request);
@ -90,7 +90,7 @@ class AccountControllerTest extends ControllerTestCase
public function testUpdateControllerForIdentity()
{
$this->setRequestMockClass(AccountDataFormRequest::class);
$user = $this->setRequestUser();
$user = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('do_action')->andReturn('identity');
$this->request->shouldReceive('only')->with(['name_first', 'name_last', 'username'])->once()->andReturn([
@ -98,7 +98,7 @@ class AccountControllerTest extends ControllerTestCase
]);
$this->updateService->shouldReceive('setUserLevel')->with(User::USER_LEVEL_USER)->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturnNull();
$this->updateService->shouldReceive('handle')->with($user, ['test_data' => 'value'])->once()->andReturn(collect());
$this->alert->shouldReceive('success->flash')->once()->andReturnNull();
$response = $this->getController()->update($this->request);

View file

@ -58,7 +58,7 @@ class SecurityControllerTest extends ControllerTestCase
*/
public function testIndexControllerWithDatabaseDriver()
{
$model = $this->setRequestUser();
$model = $this->generateRequestUserModel();
$this->config->shouldReceive('get')->with('session.driver')->once()->andReturn('database');
$this->repository->shouldReceive('getUserSessions')->with($model->id)->once()->andReturn(['sessions']);
@ -89,7 +89,7 @@ class SecurityControllerTest extends ControllerTestCase
*/
public function testGenerateTotpController()
{
$model = $this->setRequestUser();
$model = $this->generateRequestUserModel();
$this->twoFactorSetupService->shouldReceive('handle')->with($model)->once()->andReturn('qrCodeImage');
@ -103,10 +103,10 @@ class SecurityControllerTest extends ControllerTestCase
*/
public function testDisableTotpControllerSuccess()
{
$model = $this->setRequestUser();
$model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturnNull();
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andReturn(true);
$response = $this->getController()->disableTotp($this->request);
$this->assertIsRedirectResponse($response);
@ -118,7 +118,7 @@ class SecurityControllerTest extends ControllerTestCase
*/
public function testDisableTotpControllerWhenExceptionIsThrown()
{
$model = $this->setRequestUser();
$model = $this->generateRequestUserModel();
$this->request->shouldReceive('input')->with('token')->once()->andReturn('testToken');
$this->toggleTwoFactorService->shouldReceive('handle')->with($model, 'testToken', false)->once()->andThrow(new TwoFactorAuthenticationTokenInvalid);
@ -135,7 +135,7 @@ class SecurityControllerTest extends ControllerTestCase
*/
public function testRevokeController()
{
$model = $this->setRequestUser();
$model = $this->generateRequestUserModel();
$this->repository->shouldReceive('deleteUserSession')->with($model->id, 123)->once()->andReturnNull();

View file

@ -133,7 +133,7 @@ class ServerCreationServiceTest extends TestCase
$this->configurationStructureService->shouldReceive('handle')->with($model)->once()->andReturn(['test' => 'struct']);
$this->daemonServerRepository->shouldReceive('setNode')->with($model->node_id)->once()->andReturnSelf();
$this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once()->andReturnNull();
$this->daemonServerRepository->shouldReceive('create')->with(['test' => 'struct'], ['start_on_completion' => false])->once();
$this->connection->shouldReceive('commit')->withNoArgs()->once()->andReturnNull();
$response = $this->getService()->create($model->toArray());