diff --git a/CHANGELOG.md b/CHANGELOG.md index 33749dd5..36586d88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ This file is a running track of new features and fixes to each version of the pa This project follows [Semantic Versioning](http://semver.org) guidelines. +## v0.7.17 (Derelict Dermodactylus) +### Fixed +* Limited accounts to 5 API keys at a time. +* Fixes database passwords not being generated with the proper requirements for some MySQL setups. +* Hostnames that are not FQDNs/IP addresses can now be used for connecting to a MySQL host. + ## v0.7.16 (Derelict Dermodactylus) ### Fixed * Fixed the /api/application/servers endpoint erroring when including subusers or egg diff --git a/LICENSE.md b/LICENSE.md index 92953602..11eabac9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ # The MIT License (MIT) ``` -Copyright (c) 2015 - 2017 Dane Everitt +Copyright (c) 2015 - 2020 Dane Everitt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/app/Helpers/Utilities.php b/app/Helpers/Utilities.php new file mode 100644 index 00000000..5de685fe --- /dev/null +++ b/app/Helpers/Utilities.php @@ -0,0 +1,35 @@ +repository->findCountWhere(['user_id' => $request->user()->id]) >= 5) { + throw new DisplayException( + 'Cannot assign more than 5 API keys to an account.' + ); + } + $this->keyService->setKeyType(ApiKey::TYPE_ACCOUNT)->handle([ 'user_id' => $request->user()->id, 'allowed_ips' => $request->input('allowed_ips'), diff --git a/app/Models/DatabaseHost.php b/app/Models/DatabaseHost.php index c564f725..f48977b1 100644 --- a/app/Models/DatabaseHost.php +++ b/app/Models/DatabaseHost.php @@ -72,7 +72,7 @@ class DatabaseHost extends Model implements CleansAttributes, ValidableContract */ protected static $dataIntegrityRules = [ 'name' => 'string|max:255', - 'host' => 'ip|unique:database_hosts,host', + 'host' => 'unique:database_hosts,host', 'port' => 'numeric|between:1,65535', 'username' => 'string|max:32', 'password' => 'nullable|string', diff --git a/app/Services/Databases/DatabaseManagementService.php b/app/Services/Databases/DatabaseManagementService.php index d7c942cb..103befa5 100644 --- a/app/Services/Databases/DatabaseManagementService.php +++ b/app/Services/Databases/DatabaseManagementService.php @@ -3,6 +3,7 @@ namespace Pterodactyl\Services\Databases; use Pterodactyl\Models\Database; +use Pterodactyl\Helpers\Utilities; use Illuminate\Database\DatabaseManager; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; @@ -69,7 +70,9 @@ class DatabaseManagementService $data['server_id'] = $server; $data['database'] = sprintf('s%d_%s', $server, $data['database']); $data['username'] = sprintf('u%d_%s', $server, str_random(10)); - $data['password'] = $this->encrypter->encrypt(str_random(24)); + $data['password'] = $this->encrypter->encrypt( + Utilities::randomStringWithSpecialCharacters(24) + ); $this->database->beginTransaction(); try { diff --git a/app/Services/Databases/DatabasePasswordService.php b/app/Services/Databases/DatabasePasswordService.php index ed60bad4..ad5882c4 100644 --- a/app/Services/Databases/DatabasePasswordService.php +++ b/app/Services/Databases/DatabasePasswordService.php @@ -2,9 +2,8 @@ namespace Pterodactyl\Services\Databases; -use Exception; use Pterodactyl\Models\Database; -use Illuminate\Support\Facades\Log; +use Pterodactyl\Helpers\Utilities; use Illuminate\Database\ConnectionInterface; use Illuminate\Contracts\Encryption\Encrypter; use Pterodactyl\Extensions\DynamicDatabaseConnection; @@ -62,19 +61,7 @@ class DatabasePasswordService */ public function handle(Database $database): string { - $password = str_random(24); - // Given a random string of characters, randomly loop through the characters and replace some - // with special characters to avoid issues with MySQL password requirements on some servers. - try { - for ($i = 0; $i < random_int(2, 6); $i++) { - $character = ['!', '@', '=', '.', '+', '^'][random_int(0, 5)]; - - $password = substr_replace($password, $character, random_int(0, 23), 1); - } - } catch (Exception $exception) { - // Just log the error and hope for the best at this point. - Log::error($exception); - } + $password = Utilities::randomStringWithSpecialCharacters(24); $this->connection->transaction(function () use ($database, $password) { $this->dynamic->set('dynamic', $database->database_host_id); diff --git a/config/app.php b/config/app.php index 7b413170..34360e10 100644 --- a/config/app.php +++ b/config/app.php @@ -9,7 +9,7 @@ return [ | change this value if you are not maintaining your own internal versions. */ - 'version' => '0.7.16', + 'version' => '0.7.17', /* |-------------------------------------------------------------------------- diff --git a/resources/themes/pterodactyl/admin/index.blade.php b/resources/themes/pterodactyl/admin/index.blade.php index 9e9690f8..a0cb3097 100644 --- a/resources/themes/pterodactyl/admin/index.blade.php +++ b/resources/themes/pterodactyl/admin/index.blade.php @@ -45,14 +45,14 @@
 
@endsection diff --git a/resources/themes/pterodactyl/server/schedules/new.blade.php b/resources/themes/pterodactyl/server/schedules/new.blade.php index bb925c25..3202c525 100644 --- a/resources/themes/pterodactyl/server/schedules/new.blade.php +++ b/resources/themes/pterodactyl/server/schedules/new.blade.php @@ -6,7 +6,7 @@ @extends('layouts.master') @section('title') - @lang('server.schedules.new.header') + @lang('server.schedule.new.header') @endsection @section('scripts')