revert(migration) encryption
This commit is contained in:
parent
970eac94ad
commit
229c649f9a
|
@ -2,13 +2,10 @@
|
|||
|
||||
namespace Appwrite\Migration\Version;
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
use Appwrite\Database\Database;
|
||||
use Appwrite\Database\Document;
|
||||
use Appwrite\Migration\Migration;
|
||||
use Appwrite\OpenSSL\OpenSSL;
|
||||
|
||||
class V06 extends Migration
|
||||
{
|
||||
|
@ -29,41 +26,8 @@ class V06 extends Migration
|
|||
->setAttribute('passwordUpdate', $document->getAttribute('password-update', $document->getAttribute('passwordUpdate', '')))
|
||||
->removeAttribute('password-update');
|
||||
}
|
||||
if ($document->getAttribute('prefs', null)) {
|
||||
//TODO: take care of filter ['json']
|
||||
}
|
||||
break;
|
||||
case Database::SYSTEM_COLLECTION_WEBHOOKS:
|
||||
case Database::SYSTEM_COLLECTION_TASKS:
|
||||
if ($document->getAttribute('httpPass', null)) {
|
||||
$document->setAttribute('httpPass', $this->applyFilterEncrypt($document->getAttribute('httpPass')));
|
||||
}
|
||||
break;
|
||||
case Database::SYSTEM_COLLECTION_PROJECTS:
|
||||
$providers = Config::getParam('providers');
|
||||
|
||||
foreach ($providers as $key => $provider) {
|
||||
if ($document->getAttribute('usersOauth' . \ucfirst($key) . 'Secret', null)) {
|
||||
$document->getAttribute('usersOauth' . \ucfirst($key) . 'Secret', $this->applyFilterEncrypt($document->getAttribute('usersOauth' . \ucfirst($key) . 'Secret')));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $document;
|
||||
}
|
||||
|
||||
private function applyFilterEncrypt(String $value)
|
||||
{
|
||||
$key = App::getEnv('_APP_OPENSSL_KEY_V1');
|
||||
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
|
||||
$tag = null;
|
||||
|
||||
return json_encode([
|
||||
'data' => OpenSSL::encrypt($value, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag),
|
||||
'method' => OpenSSL::CIPHER_AES_128_GCM,
|
||||
'iv' => bin2hex($iv),
|
||||
'tag' => bin2hex($tag),
|
||||
'version' => '1',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue