SQLite: Require credentials to use (thanks to Vincent Waart)

This commit is contained in:
Jakub Vrana 2016-06-01 09:57:17 -07:00
parent a5b65fba5b
commit 7a33661b72
6 changed files with 12 additions and 19 deletions

View file

@ -88,16 +88,14 @@ class Adminer {
global $drivers; global $drivers;
?> ?>
<table cellspacing="0"> <table cellspacing="0">
<tr><th><?php echo lang('System'); ?><td><?php echo html_select("auth[driver]", $drivers, DRIVER, "loginDriver(this);"); ?> <tr><th><?php echo lang('System'); ?><td><?php echo html_select("auth[driver]", $drivers, DRIVER); ?>
<tr><th><?php echo lang('Server'); ?><td><input name="auth[server]" value="<?php echo h(SERVER); ?>" title="hostname[:port]" placeholder="localhost" autocapitalize="off"> <tr><th><?php echo lang('Server'); ?><td><input name="auth[server]" value="<?php echo h(SERVER); ?>" title="hostname[:port]" placeholder="localhost" autocapitalize="off">
<tr><th><?php echo lang('Username'); ?><td><input name="auth[username]" id="username" value="<?php echo h($_GET["username"]); ?>" autocapitalize="off"> <tr><th><?php echo lang('Username'); ?><td><input name="auth[username]" id="username" value="<?php echo h($_GET["username"]); ?>" autocapitalize="off">
<tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]"> <tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
<tr><th><?php echo lang('Database'); ?><td><input name="auth[db]" value="<?php echo h($_GET["db"]); ?>" autocapitalize="off"> <tr><th><?php echo lang('Database'); ?><td><input name="auth[db]" value="<?php echo h($_GET["db"]); ?>" autocapitalize="off">
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
var username = document.getElementById('username'); focus(document.getElementById('username'));
focus(username);
username.form['auth[driver]'].onchange();
</script> </script>
<?php <?php
echo "<p><input type='submit' value='" . lang('Login') . "'>\n"; echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
@ -107,9 +105,13 @@ username.form['auth[driver]'].onchange();
/** Authorize the user /** Authorize the user
* @param string * @param string
* @param string * @param string
* @return bool * @return mixed true for success, string for error message, false for unknown error
*/ */
function login($login, $password) { function login($login, $password) {
global $jush;
if ($jush == "sqlite") {
return lang('Implement %s method to use SQLite.', 'login()');
}
return true; return true;
} }

View file

@ -167,8 +167,8 @@ if (isset($_GET["username"])) {
$driver = new Min_Driver($connection); $driver = new Min_Driver($connection);
if (!is_object($connection) || !$adminer->login($_GET["username"], get_password())) { if (!is_object($connection) || ($login = $adminer->login($_GET["username"], get_password())) !== true) {
auth_error((is_string($connection) ? $connection : lang('Invalid credentials.'))); auth_error((is_string($connection) ? $connection : (is_string($login) ? $login : lang('Invalid credentials.'))));
} }
if ($auth && $_POST["token"]) { if ($auth && $_POST["token"]) {

View file

@ -11,6 +11,7 @@ $translations = array(
'Logged as: %s' => 'Přihlášen jako: %s', 'Logged as: %s' => 'Přihlášen jako: %s',
'Logout successful.' => 'Odhlášení proběhlo v pořádku.', 'Logout successful.' => 'Odhlášení proběhlo v pořádku.',
'Invalid credentials.' => 'Neplatné přihlašovací údaje.', 'Invalid credentials.' => 'Neplatné přihlašovací údaje.',
'Implement %s method to use SQLite.' => 'Pro přihlášení k SQLite implementujte metodu %s.',
'Too many unsuccessful logins, try again in %d minute(s).' => array('Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minutu.', 'Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minuty.', 'Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minut.'), 'Too many unsuccessful logins, try again in %d minute(s).' => array('Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minutu.', 'Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minuty.', 'Příliš mnoho pokusů o přihlášení, zkuste to znovu za %d minut.'),
'Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.' => 'Platnost hlavního hesla vypršela. <a href="https://www.adminer.org/cs/extension/" target="_blank">Implementujte</a> metodu %s, aby platilo stále.', 'Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.' => 'Platnost hlavního hesla vypršela. <a href="https://www.adminer.org/cs/extension/" target="_blank">Implementujte</a> metodu %s, aby platilo stále.',
'Language' => 'Jazyk', 'Language' => 'Jazyk',

View file

@ -11,6 +11,7 @@ $translations = array(
'Logged as: %s' => 'Xx', 'Logged as: %s' => 'Xx',
'Logout successful.' => 'Xx.', 'Logout successful.' => 'Xx.',
'Invalid credentials.' => 'Xx.', 'Invalid credentials.' => 'Xx.',
'Implement %s method to use SQLite.' => 'Xx.',
'Too many unsuccessful logins, try again in %d minute(s).' => array('Xx.', 'Xx.'), 'Too many unsuccessful logins, try again in %d minute(s).' => array('Xx.', 'Xx.'),
'Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.' => 'Xx.', 'Master password expired. <a href="https://www.adminer.org/en/extension/" target="_blank">Implement</a> %s method to make it permanent.' => 'Xx.',
'Language' => 'Xx', 'Language' => 'Xx',

View file

@ -60,18 +60,6 @@ function typePassword(el, disable) {
} }
} }
/** Hide or show some login rows for selected driver
* @param HTMLSelectElement
*/
function loginDriver(driver) {
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].getElementsByTagName('input')[0].disabled = disabled;
}
}
var dbCtrl; var dbCtrl;

View file

@ -1,5 +1,6 @@
Adminer 4.2.5-dev: Adminer 4.2.5-dev:
Fix remote execution in SQLite query Fix remote execution in SQLite query
SQLite: Require credentials to use
PostgreSQL: Support KILL PostgreSQL: Support KILL
Adminer 4.2.4 (released 2016-02-06): Adminer 4.2.4 (released 2016-02-06):