Skip to content

Commit b1b88e3

Browse files
committed
Change the security behaviour
* The .htpasswd file is no longer used * The .htaccess file is now used to block all direct accesses to servers, databases and table with a browser
1 parent 0b7afe0 commit b1b88e3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/JSONDB/JSONDB.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,18 @@ public function createServer($name, $username, $password, $connect = FALSE)
298298
chmod($path, 0777);
299299

300300
$htaccess = fopen($path . '/.htaccess', 'a+');
301-
foreach(array('AuthType Basic', 'AuthName "JSONDB Server Access"', 'AuthUserFile "' . realpath(dirname(dirname(__DIR__)) . '/config/.htpasswd') . '"', 'Require user ' . $username) as $line) {
301+
foreach(array('<IfModule mod_rewrite.c>',
302+
'RewriteEngine On',
303+
'RewriteRule ^index\.php$ - [L]',
304+
'RewriteRule . - [f]',
305+
'</IfModule>') as $line) {
302306
fwrite($htaccess, $line . "\n");
303307
}
304308
fclose($htaccess);
305309

306-
$htpasswd = fopen(realpath(dirname(dirname(__DIR__)) . '/config/.htpasswd'), 'a+');
307-
fwrite($htpasswd, $username . ':' . crypt($password) . "\n");
308-
fclose($htpasswd);
310+
$indexphp = fopen($path . '/index.php', 'a+');
311+
fwrite($indexphp, 'Direct Access Denied.');
312+
fclose($indexphp);
309313

310314
$this->config->addUser($name, $username, $password);
311315

0 commit comments

Comments
 (0)