Skip to content

Commit

Permalink
Support DATABASE_SSL_* env-variables (#27)
Browse files Browse the repository at this point in the history
Add Adminer plugin to support database servers requiring SSL
  • Loading branch information
maximilian-walter authored Oct 4, 2024
1 parent f98e458 commit ca8881a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Adminer/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Shopware\Core\DevOps\Environment\EnvironmentHelper;

function adminer_object()
{
include_once __DIR__ . '/plugin.php';
Expand All @@ -12,9 +14,21 @@ function adminer_object()
new AdminerFrames(true),
new AdminerTablesFilter(),
new AdminerLoginPasswordLess(),
new AdminerLoginSsl(adminer_ssl_configuration()),
]);
}

function adminer_ssl_configuration()
{
$ssl = [
'ca' => EnvironmentHelper::getVariable('DATABASE_SSL_CA'),
'cert' => EnvironmentHelper::getVariable('DATABASE_SSL_CERT'),
'key' => EnvironmentHelper::getVariable('DATABASE_SSL_KEY'),
];

return 0 < count(array_filter($ssl)) ? $ssl : null;
}

error_reporting(0);
@ini_set('display_errors', 0);

Expand Down
24 changes: 24 additions & 0 deletions src/Adminer/plugins/AdminerLoginSsl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/** Connect to MySQL using SSL
* @link https://www.adminer.org/plugins/#use
* @author Jakub Vrana, https://www.vrana.cz/
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerLoginSsl {
/** @access protected */
var $ssl;

/**
* @param array array("key" => filename, "cert" => filename, "ca" => filename)
*/
function __construct($ssl) {
$this->ssl = $ssl;
}

function connectSsl() {
return $this->ssl;
}

}

0 comments on commit ca8881a

Please sign in to comment.