Skip to content

Commit

Permalink
Merge pull request #605 from digininja/revert-592-env-config
Browse files Browse the repository at this point in the history
Revert "feat: allow configuration via environment variables"
  • Loading branch information
digininja authored Jan 16, 2024
2 parents 312293e + 1ff199e commit 3c044ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 24 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,6 @@ On Windows, this can be a bit harder if you are hiding file extensions, if you a

[How to Make Windows Show File Extensions](https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/)

### Config with Environment variables

Instead of modifing the config file you can also set most of the settings using environment variables. In a docker setup this allows to change the configuration without creating a new docker image. You can find the variables in the `config/config.inc.php.dist` file.

If you want to set the default security level to "low", just add the line to the docker-compose.yml:

```yml
environment:
- DB_SERVER=db
- DEFAULT_SECURITY_LEVEL=low
```
### Database Setup

To set up the database, simply click on the `Setup DVWA` button in the main menu, then click on the `Create / Reset Database` button. This will create / reset the database for you with some data in.
Expand Down
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
# Change `always` to `build` to build from local source
pull_policy: always
environment:
- DVWA_DB_SERVER=db
- DB_SERVER=db
depends_on:
- db
networks:
Expand Down
22 changes: 11 additions & 11 deletions config/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Thanks to @digininja for the fix.

# Database management system to use
$DBMS = getenv('DVWA_DBMS') ?: 'MySQL';
$DBMS = 'MySQL';
#$DBMS = 'PGSQL'; // Currently disabled

# Database variables
Expand All @@ -15,32 +15,32 @@ $DBMS = getenv('DVWA_DBMS') ?: 'MySQL';
# If you are using MariaDB then you cannot use root, you must use create a dedicated DVWA user.
# See README.md for more information on this.
$_DVWA = array();
$_DVWA[ 'db_server' ] = getenv('DVWA_DB_SERVER') ?: '127.0.0.1';
$_DVWA[ 'db_database' ] = getenv('DVWA_DB_DATABASE') ?: 'dvwa';
$_DVWA[ 'db_user' ] = getenv('DVWA_DB_USER') ?: 'dvwa';
$_DVWA[ 'db_password' ] = getenv('DVWA_DB_PASSWORD') ?: 'p@ssw0rd';
$_DVWA[ 'db_port'] = getenv('DVWA_DB_PORT') ?: '3306';
$_DVWA[ 'db_server' ] = getenv('DB_SERVER') ?: '127.0.0.1';
$_DVWA[ 'db_database' ] = 'dvwa';
$_DVWA[ 'db_user' ] = 'dvwa';
$_DVWA[ 'db_password' ] = 'p@ssw0rd';
$_DVWA[ 'db_port'] = '3306';

# ReCAPTCHA settings
# Used for the 'Insecure CAPTCHA' module
# You'll need to generate your own keys at: https://www.google.com/recaptcha/admin
$_DVWA[ 'recaptcha_public_key' ] = getenv('DVWA_RECAPTCHA_PUBLIC_KEY') ?: '';
$_DVWA[ 'recaptcha_private_key' ] = getenv('DVWA_RECAPTCHA_PRIVATE_KEY') ?: '';
$_DVWA[ 'recaptcha_public_key' ] = '';
$_DVWA[ 'recaptcha_private_key' ] = '';

# Default security level
# Default value for the security level with each session.
# The default is 'impossible'. You may wish to set this to either 'low', 'medium', 'high' or impossible'.
$_DVWA[ 'default_security_level' ] = getenv('DVWA_DEFAULT_SECURITY_LEVEL') ?: 'impossible';
$_DVWA[ 'default_security_level' ] = 'impossible';

# Default locale
# Default locale for the help page shown with each session.
# The default is 'en'. You may wish to set this to either 'en' or 'zh'.
$_DVWA[ 'default_locale' ] = getenv('DVWA_DEFAULT_LOCALE') ?: 'en';
$_DVWA[ 'default_locale' ] = 'en';

# Disable authentication
# Some tools don't like working with authentication and passing cookies around
# so this setting lets you turn off authentication.
$_DVWA[ 'disable_authentication' ] = getenv('DVWA_DISABLE_AUTHENTICATION') ?: false;
$_DVWA[ 'disable_authentication' ] = false;

define ('MYSQL', 'mysql');
define ('SQLITE', 'sqlite');
Expand Down

0 comments on commit 3c044ee

Please sign in to comment.