]> git.joonet.de Git - adminer.git/commitdiff
Disallow using password-less databases
authorJakub Vrana <jakub@vrana.cz>
Fri, 4 May 2018 14:52:41 +0000 (16:52 +0200)
committerJakub Vrana <jakub@vrana.cz>
Fri, 4 May 2018 14:52:41 +0000 (16:52 +0200)
16 files changed:
adminer/drivers/elastic.inc.php
adminer/drivers/mongo.inc.php
adminer/drivers/simpledb.inc.php
adminer/drivers/sqlite.inc.php
adminer/include/adminer.inc.php
adminer/lang/cs.inc.php
adminer/lang/he.inc.php
adminer/lang/ms.inc.php
adminer/lang/pl.inc.php
adminer/lang/ru.inc.php
adminer/lang/tr.inc.php
adminer/lang/xx.inc.php
adminer/sqlite.php
changes.txt
plugins/login-password-less.php [new file with mode: 0644]
plugins/login-sqlite.php [deleted file]

index e0dcbe0cc2271f9bccd709f7e1e1d7e511c90818..97677f3c50670f5088abfa755ac11555ad89147e 100644 (file)
@@ -227,8 +227,11 @@ if (isset($_GET["elastic"])) {
        function connect() {
                global $adminer;
                $connection = new Min_DB;
-               $credentials = $adminer->credentials();
-               if ($connection->connect($credentials[0], $credentials[1], $credentials[2])) {
+               list($server, $username, $password) = $adminer->credentials();
+               if ($password != "" && $connection->connect($server, $username, "")) {
+                       return lang('Database does not support password.');
+               }
+               if ($connection->connect($server, $username, $password)) {
                        return $connection;
                }
                return $connection->error;
index 6a39e3173c381cad51d024bad5ac9ced1249a8d5..6fc01308c422d839537e17d4901da8261cc93d8c 100644 (file)
@@ -610,7 +610,7 @@ if (isset($_GET["mongo"])) {
                $connection = new Min_DB;
                list($server, $username, $password) = $adminer->credentials();
                $options = array();
-               if ($username != "") {
+               if ($username . $password != "") {
                        $options["username"] = $username;
                        $options["password"] = $password;
                }
@@ -620,6 +620,15 @@ if (isset($_GET["mongo"])) {
                }
                try {
                        $connection->_link = $connection->connect("mongodb://$server", $options);
+                       if ($password != "") {
+                               $options["password"] = "";
+                               try {
+                                       $connection->connect("mongodb://$server", $options);
+                                       return lang('Database does not support password.');
+                               } catch (Exception $ex) {
+                                       // this is what we want
+                               }
+                       }
                        return $connection;
                } catch (Exception $ex) {
                        return $ex->getMessage();
index 040309c5d99e71dc487adc1620c35b8f1f97a776..7bf8a780df2e59a94edf7f3b76f69221e7f53107 100644 (file)
@@ -248,6 +248,11 @@ if (isset($_GET["simpledb"])) {
 
 
        function connect() {
+               global $adminer;
+               list(, , $password) = $adminer->credentials();
+               if ($password != "") {
+                       return lang('Database does not support password.');
+               }
                return new Min_DB;
        }
 
index c688e7741850e8eeefd28c92d35c3a4a998aea95..fbf00c2c9ae450097195a59a31ec402e29540b58 100644 (file)
@@ -240,6 +240,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
        }
 
        function connect() {
+               global $adminer;
+               list(, , $password) = $adminer->credentials();
+               if ($password != "") {
+                       return lang('Database does not support password.');
+               }
                return new Min_DB;
        }
 
index 4d2f5b3ae6897c1089cb4c0568dcf3613d0d7286..733adf7de8ba5dabd452e9f2366e61a40491b142 100644 (file)
@@ -145,9 +145,8 @@ class Adminer {
        * @return mixed true for success, string for error message, false for unknown error
        */
        function login($login, $password) {
-               global $jush;
-               if ($jush == "sqlite") {
-                       return lang('<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.', target_blank(), '<code>login()</code>');
+               if ($password == "") { //! password is optional in Elastic and Mongo
+                       return lang('<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use password-less database.', target_blank(), '<code>login()</code>');
                }
                return true;
        }
index 20e3095a773eab7e741b0877f66981852230c8e1..6c89f521915f00df552c8c224fa14ca81b4e0186 100644 (file)
@@ -12,7 +12,8 @@ $translations = array(
        'Logout successful.' => 'Odhlášení proběhlo v pořádku.',
        'Thanks for using Adminer, consider <a href="%s">donating</a>.' => 'Díky za použití Admineru, <a href="%s">příspějte</a> na vývoj.',
        'Invalid credentials.' => 'Neplatné přihlašovací údaje.',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => 'Pro přihlášení k SQLite <a href="https://www.adminer.org/cs/extension/"%s>implementujte</a> metodu %s.',
+       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use password-less database.' => 'Pro přihlášení bez hesla <a href="https://www.adminer.org/cs/extension/"%s>implementujte</a> metodu %s.',
+       'Database does not support password.' => 'Databáze nepodporuje heslo.',
        '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/"%s>Implement</a> %s method to make it permanent.' => 'Platnost hlavního hesla vypršela. <a href="https://www.adminer.org/cs/extension/"%s>Implementujte</a> metodu %s, aby platilo stále.',
        'Language' => 'Jazyk',
index 57e19d6a95d2656a08b38c4cdaefea5f30c16557..d206af3301d6183b9aa34ed55429719e94c88c26 100644 (file)
@@ -276,7 +276,6 @@ $translations = array(
        'ATTACH queries are not supported.' => 'שאילתת ATTACH אינה נתמכת',
        '%d / ' => '%d / ',
        'Limit rows' => 'הגבל שורות',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => '<a href="https://www.adminer.org/en/extension/"%s>התקן</a> את תוסף SQLite בשביל להתחבר',
        'Default value' => 'ערך ברירת מחדל',
        'Full table scan' => 'סריקה טבלה מלאה',
        'Too many unsuccessful logins, try again in %d minute(s).' => 'יותר מידי נסיונות כניסה נכשלו, אנא נסה עוד %d דקות',
index 84416dd283c5b54a43b8c217e0be29539c621483..58f2141d99995083d06200d05c5312e88c1efc70 100644 (file)
@@ -12,7 +12,6 @@ $translations = array(
        'Logout successful.' => 'Log keluar berjaya.',
        'Thanks for using Adminer, consider <a href="%s">donating</a>.' => 'Terima kasih kerana menggunakan Adminer, pertimbangkan untuk <a href="%s">menderma</a>.',
        'Invalid credentials.' => 'Akses tidak sah.',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => '<a href="https://www.adminer.org/en/extension/"%s>Gunakan</a> cara %s untuk menggunakan SQLite.',
        'Too many unsuccessful logins, try again in %d minute(s).' => 'Terlalu banyak percubaan log masuk yang gagal, sila cuba lagi dalam masa %d minit.',
        'Master password expired. <a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to make it permanent.' => 'Kata laluan utama telah luput. <a href="https://www.adminer.org/en/extension/"%s>Gunakan</a> cara %s untuk mengekalkannya.',
        'Language' => 'Bahasa',
index ac78583687d42fb5e323086a8abd70fee39957a0..11da20c6f66b34a9e2c3f6b7325aaf6c8d4b4d23 100644 (file)
@@ -12,7 +12,6 @@ $translations = array(
        'Logout successful.' => 'Wylogowano pomyślnie.',
        'Thanks for using Adminer, consider <a href="%s">donating</a>.' => 'Dziękujemy za używanie Adminera, rozważ proszę <a href="%s">dotację</a>.',
        'Invalid credentials.' => 'Nieprawidłowe dane logowania.',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => '<a href="https://www.adminer.org/pl/extension/"%s>Zaimplementuj</a> metodę %s aby użyć SQLite.',
        'Too many unsuccessful logins, try again in %d minute(s).' => array('Za dużo nieudanych prób logowania, spróbuj ponownie za %d minutę.', 'Za dużo nieudanych prób logowania, spróbuj ponownie za %d minuty.', 'Za dużo nieudanych prób logowania, spróbuj ponownie za %d minut.'),
        'Master password expired. <a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to make it permanent.' => 'Ważność hasła głównego wygasła. <a href="https://www.adminer.org/pl/extension/"%s>Zaimplementuj</a> własną metodę %s, aby ustawić je na stałe.',
        'Language' => 'Język',
index 290ffb5540da848c7e851c71b0d5097b3c62388c..fab11f988c7eb870e0de6b56cb6d98fd403cad9f 100644 (file)
@@ -276,7 +276,6 @@ $translations = array(
        'ATTACH queries are not supported.' => 'ATTACH-запросы не поддерживаются.',
        '%d / ' => '%d / ',
        'Limit rows' => 'Лимит строк',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => '<a href="https://www.adminer.org/en/extension/"%s>Реализуйте</a> метод %s, чтобы использовать SQLite.',
        'Default value' => 'Значение по умолчанию',
        'Full table scan' => 'Анализ полной таблицы',
        'Too many unsuccessful logins, try again in %d minute(s).' => array('Слишком много неудачных попыток входа. Попробуйте снова через %d минуту.', 'Слишком много неудачных попыток входа. Попробуйте снова через %d минуты.', 'Слишком много неудачных попыток входа. Попробуйте снова через %d минут.'),
index d888de93fcde9db05c91b9ae367dbff5a528ce70..56818be38e57238477d55a642c5fc2f8da0fef14 100644 (file)
@@ -12,7 +12,6 @@ $translations = array(
        'Logout successful.' => 'Oturum başarıyla sonlandı.',
        'Thanks for using Adminer, consider <a href="%s">donating</a>.' => 'Adminer kullandığınız için teşekkür ederiz <a href="%s">bağış yapmayı düşünün</a>.',
        'Invalid credentials.' => 'Geçersiz kimlik bilgileri.',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => 'SQLite kullanmak için <a href="https://www.adminer.org/en/extension/"%s>%s metodunu</a> kullanın.',
        'Too many unsuccessful logins, try again in %d minute(s).' => array('Çok fazla oturum açma denemesi yapıldı.', '%d Dakika sonra tekrar deneyiniz.'),
        'Master password expired. <a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to make it permanent.' => 'Ana şifrenin süresi doldu. Kalıcı olması için <a href="https://www.adminer.org/en/extension/"%s>%s medodunu</a> kullanın.',
        'Language' => 'Dil',
index a91170bc0ed41bdbb0ed361be65c7fe6effd2aad..ba6d7a01065e6fdefe5e5a286960defb30c054bd 100644 (file)
@@ -12,7 +12,8 @@ $translations = array(
        'Logout successful.' => 'Xx.',
        'Thanks for using Adminer, consider <a href="%s">donating</a>.' => 'Xx <a href="%s">xx</a>.',
        'Invalid credentials.' => 'Xx.',
-       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use SQLite.' => '<a href="https://www.adminer.org/en/extension/"%s>Xx</a> %s xx.',
+       '<a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to use password-less database.' => '<a href="https://www.adminer.org/en/extension/"%s>Xx</a> %s xx.',
+       'Database does not support password.' => 'Xx.',
        'Too many unsuccessful logins, try again in %d minute(s).' => array('Xx %d.', 'Xx %d.'),
        'Master password expired. <a href="https://www.adminer.org/en/extension/"%s>Implement</a> %s method to make it permanent.' => '<a href="https://www.adminer.org/en/extension/"%s>Xx</a> %s xx.',
        'Language' => 'Xx',
index 5f6f219c0b510e3aa69514bc4c36dbc6d13237ec..41ff2e20946fdb1696d829559c5cffa7a7e846b2 100644 (file)
@@ -1,8 +1,10 @@
 <?php
 function adminer_object() {
        include_once "../plugins/plugin.php";
-       include_once "../plugins/login-sqlite.php";
-       return new AdminerPlugin(array(new AdminerLoginSqlite("admin", password_hash("", PASSWORD_DEFAULT))));
+       include_once "../plugins/login-password-less.php";
+       return new AdminerPlugin(array(
+               new AdminerLoginPasswordLess(password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT)),
+       ));
 }
 
 include "./index.php";
index 443767fa33160b00ac2c49c328619ca7205430f0..2b0dd3e6c8b6541e322a879bda5f5adc1cd8a8b4 100644 (file)
@@ -1,4 +1,5 @@
 Adminer 4.6.3-dev:
+Disallow using password-less databases
 Stop session before connecting
 Simplify running slow queries
 Decrease timeout for running slow queries from 5 seconds to 2 seconds
diff --git a/plugins/login-password-less.php b/plugins/login-password-less.php
new file mode 100644 (file)
index 0000000..2a0a50d
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+/** Enable login for password-less database
+* @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 AdminerLoginPasswordLess {
+       /** @access protected */
+       var $password_hash;
+       
+       /** Set allowed password
+       * @param string result of password_hash
+       */
+       function __construct($password_hash) {
+               $this->password_hash = $password_hash;
+       }
+
+       function credentials() {
+               $password = get_password();
+               return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
+       }
+       
+       function login($login, $password) {
+               if ($password != "") {
+                       return true;
+               }
+       }
+
+}
diff --git a/plugins/login-sqlite.php b/plugins/login-sqlite.php
deleted file mode 100644 (file)
index 1bb31dd..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/** 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 {
-       /** @access protected */
-       var $login, $password_hash;
-       
-       /** Set allowed credentials
-       * @param string
-       * @param string result of password_hash
-       */
-       function __construct($login, $password_hash) {
-               $this->login = $login;
-               $this->password_hash = $password_hash;
-       }
-       
-       function login($login, $password) {
-               if (DRIVER != "sqlite" && DRIVER != "sqlite2") {
-                       return true;
-               }
-               return $this->login == $login && password_verify($password, $this->password_hash);
-       }
-
-}