mirror of
https://github.com/Poniverse/Pony.fm.git
synced 2024-11-25 06:27:59 +01:00
#108: Switching to Laravel's new encryption
This commit is contained in:
parent
40e1b050ae
commit
19d6dd7890
5 changed files with 631 additions and 488 deletions
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Poniverse\Ponyfm\Console\Commands;
|
||||
|
||||
use DB;
|
||||
use Illuminate\Console\Command;
|
||||
use Laravel\LegacyEncrypter\McryptEncrypter;
|
||||
|
||||
class MigrateEncryption extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'migrate-encryption';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Migrates from mcrypt to openssl. Needs key and mcryptKey set in config/app.php';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$key = $this->laravel['config']['app.mcryptKey'];
|
||||
$cipher = $this->laravel['config']['app.mcryptCipher'];
|
||||
|
||||
$legacy = new McryptEncrypter($key, $cipher);
|
||||
|
||||
$caches = DB::select('SELECT * FROM cache');
|
||||
|
||||
foreach ($caches as $cache) {
|
||||
$newValue = encrypt(
|
||||
$legacy->decrypt($cache->value)
|
||||
);
|
||||
|
||||
DB::update('UPDATE cache SET value = ? WHERE key = ?', [$cache->key, $newValue]);
|
||||
|
||||
$this->info("Updated {$cache->key}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,7 +23,6 @@ namespace Poniverse\Ponyfm\Providers;
|
|||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Laravel\LegacyEncrypter\McryptEncrypter;
|
||||
use PfmValidator;
|
||||
use Poniverse;
|
||||
use Validator;
|
||||
|
@ -49,15 +48,6 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
// TODO: Migrate from Mcrypt
|
||||
$this->app->singleton('encrypter', function ($app) {
|
||||
$config = $app->make('config')->get('app');
|
||||
|
||||
$key = $config['key'];
|
||||
|
||||
return new McryptEncrypter($key, $config['cipher']);
|
||||
});
|
||||
|
||||
$this->app->bind(Poniverse::class, function (Application $app) {
|
||||
return new Poniverse($app['config']->get('poniverse.client_id'), $app['config']->get('poniverse.secret'));
|
||||
});
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
"predis/predis": "^1.0",
|
||||
"ksubileau/color-thief-php": "^1.3",
|
||||
"graham-campbell/exceptions": "^9.1",
|
||||
"minishlink/web-push": "^1.0",
|
||||
"laravel/legacy-encrypter": "^1.0"
|
||||
"minishlink/web-push": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "~1.4",
|
||||
|
|
1046
composer.lock
generated
1046
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -95,7 +95,7 @@ return [
|
|||
|
||||
'key' => env('APP_KEY'),
|
||||
|
||||
'cipher' => MCRYPT_RIJNDAEL_128,
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue