-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #454 from nextcloud/backport/451/stable30
[stable30] (fix): Encrypt sensitive values(haproxy_password) in the DB
- Loading branch information
Showing
5 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ to join us in shaping a more versatile, stable, and secure app landscape. | |
*Your insights, suggestions, and contributions are invaluable to us.* | ||
]]></description> | ||
<version>4.0.0</version> | ||
<version>4.0.3</version> | ||
<licence>agpl</licence> | ||
<author mail="[email protected]" homepage="https://github.com/andrey18106">Andrey Borysenko</author> | ||
<author mail="[email protected]" homepage="https://github.com/bigcat88">Alexander Piskun</author> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OCA\AppAPI\Migration; | ||
|
||
use Closure; | ||
use OCP\DB\ISchemaWrapper; | ||
use OCP\IDBConnection; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\SimpleMigrationStep; | ||
use OCP\Security\ICrypto; | ||
|
||
class Version5000Date20241120135411 extends SimpleMigrationStep { | ||
|
||
public function __construct( | ||
private IDBConnection $connection, | ||
private ICrypto $crypto, | ||
) { | ||
} | ||
|
||
/** | ||
* @param IOutput $output | ||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
* @param array $options | ||
* | ||
* @return null|ISchemaWrapper | ||
*/ | ||
public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options) { | ||
// encrypt "haproxy_password" in the "ex_apps_daemons" table | ||
$qbSelect = $this->connection->getQueryBuilder(); | ||
$qbSelect->select(['id', 'deploy_config']) | ||
->from('ex_apps_daemons') | ||
->where(1); | ||
$req = $qbSelect->executeQuery(); | ||
|
||
while ($row = $req->fetch()) { | ||
$deployConfig = $row['deploy_config']; | ||
$deployConfig = json_decode($deployConfig, true); | ||
if (!empty($deployConfig['haproxy_password'])) { | ||
$deployConfig['haproxy_password'] = $this->crypto->encrypt($deployConfig['haproxy_password']); | ||
$encodedDeployConfig = json_encode($deployConfig); | ||
$qbUpdate = $this->connection->getQueryBuilder(); | ||
$qbUpdate->update('ex_apps_daemons') | ||
->set('deploy_config', $qbUpdate->createNamedParameter($encodedDeployConfig)) | ||
->where( | ||
$qbUpdate->expr()->eq('id', $qbUpdate->createNamedParameter($row['id'])) | ||
); | ||
$qbUpdate->executeStatement(); | ||
} | ||
} | ||
$req->closeCursor(); | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters