This answer applies to Adminer version 4.2.5. Unfortunately, it is not valid for Adminer 4.3.x.
You need to override the login and databases methods of the Adminer class, making sure you do it only for the SQLite driver, not in other cases. The following code achieves a basic login system with a list of databases:
<?php
function adminer_object() {
class AdminerSoftware extends Adminer {
function login($login, $password) {
global $jush;
if ($jush == "sqlite")
return ($login === 'admin') && ($password === 'changeme');
return true;
}
function databases($flush = true) {
if (isset($_GET['sqlite']))
return ["/path/to/first.db", "/path/to/second.db"];
return get_databases($flush);
}
}
return new AdminerSoftware;
}
include "./adminer-4.2.5.php";
The code could be adapted to support multiple users. Save the file as index.php in the same directory where adminer-4.2.5.php is located. Make sure to tweak the username, password and paths to the databases.
Here are some important remarks:
- the
login method is not properly named, it is an initial check performed by Adminer
- for databases that have built-in user functionality, e.g. MySQL, this method should always return
true like the original class does
- SQLite files do not have built-in authentication, therefore we define an artificial check to prevent unauthorized access
Result
