1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 07:36:44 +02:00

Require specifying credentials in login-sqlite plugin

This commit is contained in:
Jakub Vrana
2018-01-16 16:37:59 +01:00
parent 0268aba85a
commit b3d5c9affe
2 changed files with 18 additions and 25 deletions

View File

@@ -2,7 +2,7 @@
function adminer_object() {
include_once "../plugins/plugin.php";
include_once "../plugins/login-sqlite.php";
return new AdminerPlugin(array(new AdminerLoginSqlite));
return new AdminerPlugin(array(new AdminerLoginSqlite("admin", password_hash("", PASSWORD_DEFAULT))));
}
include "./index.php";

View File

@@ -1,36 +1,29 @@
<?php
/** Enable auto-login for SQLite
/** Enable login for SQLite
* @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 AdminerLoginSqlite {
var $login;
var $password_hash;
/**
* @param string
* @param string result of password_hash
*/
function AdminerLoginSqlite($login, $password_hash) {
$this->login = $login;
$this->password_hash = $password_hash;
}
function login($login, $password) {
if (DRIVER != "sqlite" && DRIVER != "sqlite2") {
return true;
}
function loginForm() {
?>
<script<?php echo nonce(); ?>>
addEventListener('load', function () {
var driver = qs('name="auth[driver]"');
if (isTag(driver, 'select')) {
driver.onchange = function () {
var trs = parentTag(driver, 'table').rows;
for (var i=1; i < trs.length - 1; i++) {
var disabled = /sqlite/.test(driver.value);
alterClass(trs[i], 'hidden', disabled);
trs[i].querySelector('input').disabled = disabled;
}
};
}
driver.onchange();
});
</script>
<?php
return $this->login == $login && password_verify($password, $this->password_hash);
}
}