TimWolla / docker-adminer

Database management in a single PHP file
https://hub.docker.com/_/adminer/
157 stars 69 forks source link

how to login sqlite file without password? #162

Open geekyouth opened 8 months ago

geekyouth commented 8 months ago

this is my docker-compose.yaml

services:
  adminer:
    image: adminer:4.8.1-standalone
    # restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      TZ: Asia/Shanghai
      ADMINER_DEFAULT_SERVER: mysql57
      ADMINER_DESIGN: hydra
      ADMINER_PLUGINS: 'tables-filter tinymce login-password-less'
    volumes:
      - ./hydra.css:/var/www/html/designs/hydra/adminer.css:ro  # fix hydra style
      - ./demo/sqlite.db:/demo/sqlite.db

after run ,the error log as blow:

2023-12-09T06:00:46.570928858Z Unable to load plugin file "login-password-less", because it has required parameters: password_hash
2023-12-09T06:00:46.570946114Z Create a file "/var/www/html/plugins-enabled/login-password-less.php" with the following contents to load the plugin:
2023-12-09T06:00:46.570947891Z 
2023-12-09T06:00:46.570948996Z <?php
2023-12-09T06:00:46.570950347Z require_once('plugins/login-password-less.php');
2023-12-09T06:00:46.570951422Z 
2023-12-09T06:00:46.570952603Z /** Set allowed password
2023-12-09T06:00:46.570953684Z  * @param string result of password_hash
2023-12-09T06:00:46.570954791Z  */
2023-12-09T06:00:46.570955832Z return new AdminerLoginPasswordLess(
2023-12-09T06:00:46.570956911Z  $password_hash = ???
2023-12-09T06:00:46.570957973Z );

then as ablove guide,i mount file login-password-less.php :

<?php
require_once('plugins/login-password-less.php');

/** Set allowed password
    * @param string result of password_hash
    */
return new AdminerLoginPasswordLess(
    $password_hash = password_hash("admin", PASSWORD_BCRYPT)
);

now my docker-compose.yaml like this ( onle add a line - ./login-password-less.php:/var/www/html/plugins-enabled/login-password-less.php ):


services:
  adminer:
    image: adminer:4.8.1-standalone
    # restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      TZ: Asia/Shanghai
      ADMINER_DEFAULT_SERVER: mysql57
      ADMINER_DESIGN: hydra
      ADMINER_PLUGINS: 'tables-filter tinymce login-password-less'
    volumes:
      - ./hydra.css:/var/www/html/designs/hydra/adminer.css:ro  # fix hydra style
      - ./demo/sqlite.db:/demo/sqlite.db
      - ./login-password-less.php:/var/www/html/plugins-enabled/login-password-less.php

after run docker compose down -v; docker compose up -d , i recived the same error:

image

then i add /var/www/html/plugins-enabled/sqlite.php file https://github.com/TimWolla/docker-adminer/issues/78 :


<?php
require("plugins/login-password-less.php");
// TODO: inline the result of password_hash() so that the password is not visible in source codes
return new AdminerLoginPasswordLess(password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT));

and mount with docker-compose.yaml as blow


services:
  adminer:
    image: adminer:4.8.1-standalone
    # restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      TZ: Asia/Shanghai
      ADMINER_DEFAULT_SERVER: mysql57
      ADMINER_DESIGN: hydra
      ADMINER_PLUGINS: 'tables-filter tinymce'
    volumes:
      - ./hydra.css:/var/www/html/designs/hydra/adminer.css:ro  # fix hydra style
      - ./demo/sqlite.db:/demo/sqlite.db
      #- ./login-password-less2.php:/var/www/html/plugins-enabled/login-password-less.php
      - ./sqlite.php:/var/www/html/plugins-enabled/sqlite.php

after run docker compose up -d;

it works:

image

but it is readonly

image

geekyouth commented 8 months ago

method2:

services:
  adminer:
    image: adminer:4.8.1-standalone
    # restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      TZ: Asia/Shanghai
      ADMINER_DEFAULT_SERVER: mysql57
      ADMINER_DESIGN: hydra
      ADMINER_PLUGINS: 'tables-filter tinymce'
    volumes:
      - ./hydra.css:/var/www/html/designs/hydra/adminer.css:ro  # fix hydra style
      - ./demo/:/demo/:rw
      - ./login-password-less.php:/var/www/html/plugins-enabled/login-password-less.php

./login-password-less.php


<?php
require_once('plugins/login-password-less.php');

/** Set allowed password
 * @param string result of password_hash
 */
return new AdminerLoginPasswordLess(
  $password_hash = password_hash("admin", PASSWORD_DEFAULT)
);

now the sqlite is writeable with - ./demo/:/demo/:rw