Skip to content

Commit 169c911

Browse files
committed
Remove option to store cleartext passwords in config
This is bad practice, and we should not be enabling it.
1 parent c4a9dae commit 169c911

File tree

9 files changed

+20
-35
lines changed

9 files changed

+20
-35
lines changed

docker/defaults.env

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,11 @@ HOSTERS_HOF_URL=
6161
# manual HoF pages to include
6262
MANUAL_HOF_PAGES=
6363

64-
# comma separated user:password pairs for /grafana and /prometheus metrics endpoints
65-
MONITORING_AUTH=
66-
# comma separated user:password pairs for side wide authentication
67-
BASIC_AUTH=
68-
69-
# comma separated of IP(v6) addresses/subnets that are allowed to access the website without a password when BASIC_AUTH is enabled
64+
# comma separated of IP(v6) addresses/subnets that are allowed to access the website without a password when BASIC_AUTH_RAW is enabled
7065
ALLOW_LIST=
7166

72-
# comma separated user:htpasswd_encrypted pairs, same AUTH above, except password must already be encrypted
67+
# comma separated user:htpasswd_encrypted pairs for /grafana and /prometheus, and side wide
68+
# password must already be encrypted
7369
# please not that the value needs to be enclosed by single quotes to prevent interpolation of the dollar signs
7470
# eg: BASIC_AUTH_RAW='test1:$apr1$wGM8gxBe$DxGwifTGWZJ7nftK7LzFt/,user2:$apr1$BoZzsbb/$2NgfYCfF9lxmGrfSqsZKc/'
7571
MONITORING_AUTH_RAW=

docker/develop.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ COMPOSE_PROJECT_NAME=internetnl-develop
1111
# enable for testing batch api
1212
ENABLE_BATCH=True
1313

14-
# use easy user/passwords for authenticated endpoints
15-
MONITORING_AUTH=test:test
14+
# use easy test/test user/passwords for authenticated endpoints
15+
MONITORING_AUTH='test:$apr1$PfpYZVWM$tLUKMXt91KJV6I.CF3TOt1'
1616

1717
LETSENCRYPT_STAGING=1
1818
LETSENCRYPT_EMAIL=[email protected]

docker/docker-compose.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ services:
2626
environment:
2727
- INTERNETNL_DOMAINNAME
2828
- IPV6_TEST_ADDR
29-
- MONITORING_AUTH
30-
- BASIC_AUTH
3129
- MONITORING_AUTH_RAW
3230
- BASIC_AUTH_RAW
3331
- ALLOW_LIST

docker/test.env

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ TEST_TARGET_DOMAINNAME=target.test
5353
IPV6_IP_TEST_TARGET_PUBLIC=fd00:43:1::51
5454
IPV6_IP_TEST_TARGET_MAIL_PUBLIC=fd00:43:1::52
5555

56-
# use easy user/passwords for authenticated endpoints
57-
MONITORING_AUTH=test:test
58-
MONITORING_AUTH_RAW='test_raw:$apr1$6YuDyduL$706z.FPTe5c09R767N3W90'
56+
# use easy test/test user/passwords for authenticated endpoints
57+
MONITORING_AUTH_RAW='test:$apr1$PfpYZVWM$tLUKMXt91KJV6I.CF3TOt1,test_raw:$apr1$6YuDyduL$706z.FPTe5c09R767N3W90'
5958

6059
# use lower scheduler interval to speed up batch API tests
6160
BATCH_SCHEDULER_INTERVAL=3

docker/webserver/authentication.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# enable basic auth when user/password is configured
3-
if [ ! "$BASIC_AUTH" = "" ] || [ ! "$BASIC_AUTH_RAW" = "" ];then
3+
if [ ! "$BASIC_AUTH_RAW" = "" ];then
44
echo 'auth_basic "Please enter your username and password";auth_basic_user_file /etc/nginx/htpasswd/basic_auth.htpasswd;' > /etc/nginx/conf.d/basic_auth.conf
55
fi
66

@@ -15,7 +15,7 @@ if [ ! "$ALLOW_LIST" = "" ];then
1515
fi
1616

1717
# verify that when debug is enabled, authentication is also enabled
18-
if [ ! "$DEBUG" = "False" ] && [ "$BASIC_AUTH$BASIC_AUTH_RAW$ALLOW_LIST" = "" ];then
19-
printf "\nMust have BASIC_AUTH, BASIC_AUTH_RAW or ALLOW_LIST authentication configured if DEBUG is not 'False'!\n"
18+
if [ ! "$DEBUG" = "False" ] && [ "$BASIC_AUTH_RAW$ALLOW_LIST" = "" ];then
19+
printf "\nMust have BASIC_AUTH_RAW or ALLOW_LIST authentication configured if DEBUG is not 'False'!\n"
2020
exit 1
2121
fi

docker/webserver/generate_htpasswd.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# generate htaccess files from environment variables. Add a user:password for every comma separated pair
2-
echo $MONITORING_AUTH|tr ',' '\n'|tr ':' ' '| xargs --max-args=2 --no-run-if-empty htpasswd -b /etc/nginx/htpasswd/monitoring.htpasswd
3-
echo $BASIC_AUTH|tr ',' '\n'|tr ':' ' '| xargs --max-args=2 --no-run-if-empty htpasswd -b /etc/nginx/htpasswd/basic_auth.htpasswd
4-
51
# append raw entries to htpasswd file
62
echo $MONITORING_AUTH_RAW|tr ',' '\n' >> /etc/nginx/htpasswd/monitoring.htpasswd
73
echo $BASIC_AUTH_RAW|tr ',' '\n' >> /etc/nginx/htpasswd/basic_auth.htpasswd

documentation/Docker-deployment-batch.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@ Batch installations require the following settings:
103103

104104
And optionally:
105105

106-
- `MONITORING_AUTH`: May be a comma separated list of `user:password` pairs which are allowed to access the metrics at `https://example.com/grafana/`.
107-
- `BASIC_AUTH`, `BASIC_AUTH_RAW` and `ALLOW_LIST`: Can be set to restrict access to the single scan webpage. See [Restricting Access](Docker-deployment.md#restricting-access) for more information.
106+
- `MONITORING_AUTH_RAW`: May be a comma separated list of `user:password` pairs which are allowed to access the metrics at `https://example.com/grafana/`.
107+
- `BASIC_AUTH_RAW` and `ALLOW_LIST`: Can be set to restrict access to the single scan webpage. See [Restricting Access](Docker-deployment.md#restricting-access) for more information.
108108

109109
For example:
110110

111111
cat >> docker/local.env <<EOF
112112
ENABLE_BATCH=True
113113
ENABLE_HOF=False
114114
# user/password(s) for access to /grafana monitoring
115-
MONITORING_AUTH=user:welkom01
115+
MONITORING_AUTH_RAW=user:<htpasswd hash>
116116
# user/password(s) for access to web interface
117-
BASIC_AUTH=user:welkom01
117+
BASIC_AUTH_RAW=user:<htpasswd hash>
118118
# allowed IP's to visit web interface without password
119119
ALLOW_LIST=198.51.100.1,2001:db8:2::1
120120
EOF

documentation/Docker-deployment.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ Besides the single scan webpage, the Internet.nl application also contains a Bat
301301

302302
## Metrics (grafana/prometheus)
303303

304-
The default deployment includes a metrics collection system. It consists of a Prometheus metrics server with various exporters and a Grafana frontend. To view metrics and graphs visit: `https://example.com/grafana/`. Authentication is configured using the `MONITORING_AUTH` variable.
304+
The default deployment includes a metrics collection system. It consists of a Prometheus metrics server with various exporters and a Grafana frontend. To view metrics and graphs visit: `https://example.com/grafana/`. Authentication is configured using the `MONITORING_AUTH_RAW` variable.
305305

306306
Also see: [Metrics](Docker-metrics.md)
307307

@@ -353,17 +353,13 @@ By default the installation is open to everyone. If you like to restrict access
353353

354354
### HTTP Basic Authentication
355355

356-
Site wide HTTP Basic Authentication is configured `BASIC_AUTH` and `BASIC_AUTH_RAW` variable. They should contain comma separated `user:password` or `user:encrypted_password` entries.
356+
Site wide HTTP Basic Authentication is configured `BASIC_AUTH_RAW` variable. This should contain comma separated `user:encrypted_password` entries.
357357

358-
The allow only the user `example_user` with password `secret123` to access the site add the following in the `docker/local.env` file:
359-
360-
BASIC_AUTH=example_user:secret123
361-
362-
Aditionally the password can already be provided as encrypted value. For this encrypt the password using the `htpasswd` tool and use the `BASIC_AUTH_RAW` variable. Make sure to enclose the value with single quotes:
358+
To allow only the user `example_user` with password `secret123` to access the site add the following in the `docker/local.env` file:
363359

364360
BASIC_AUTH_RAW='example_user:$apr1$trHqgfkY$tIpKCOuSHLfYa20HVzyaX.'
365361

366-
Both variables can be used at the same time, however, **do not list a user in both variables**.
362+
Make sure to enclose the value with single quotes.
367363

368364
### IP allow/deny lists
369365

@@ -375,7 +371,7 @@ For example, to only allow the IP addresses `198.51.100.1` and `2001:db8:2::1` a
375371

376372
### Combining HTTP Basic Authentication and IP allow lists
377373

378-
When setting boat `BASIC_AUTH(_RAW)` and `ALLOW_LIST`, users connecting from an IP in the allow list won't be prompted for a password.
374+
When setting both `BASIC_AUTH_RAW` and `ALLOW_LIST`, users connecting from an IP in the allow list won't be prompted for a password.
379375

380376
## Renewing DNSSEC after IP/hostname change
381377

documentation/Docker-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The Docker deployment includes a metrics collection system which is available on production as well as development/test environments. It consists of a Prometheus metrics server which scrapes metrics from various exporters. Grafana is provided as frontend to visualise metrics and create graphs/dashboards.
44

5-
To view metrics and graphs visit the `/grafana/` endpoint. Eg: `http://localhost:8080/grafana/` for development and `https://example.com/grafana/` for production. For development the user/password is set to `test/test`, for production users can be configured using the `MONITORING_AUTH` variable in `docker/local.env` (see `docker/defaults.env` for information).
5+
To view metrics and graphs visit the `/grafana/` endpoint. Eg: `http://localhost:8080/grafana/` for development and `https://example.com/grafana/` for production. For development the user/password is set to `test/test`, for production users can be configured using the `MONITORING_AUTH_RAW` variable in `docker/local.env` (see `docker/defaults.env` for information).
66

77
Metrics collection is defined in the `docker/docker-compose-monitoring.yml` file.
88

0 commit comments

Comments
 (0)