Skip to content

Commit 8156fd8

Browse files
committed
Merge #713: Make secrets in config options mandatory
cb0e375 fix: [#653] rename auth.secret_key config option (Jose Celano) 7b3cc13 fix: [710] make secrets in config options mandatory (Jose Celano) Pull request description: Make secrets in config options mandatory: - `tracker.token` - `auth.user_claim_token_pepper` It keeps the SMPT server credentials default because they are not always needed: - `mail.smpt.credentials.password` For example, for the mailcatcher. ACKs for top commit: josecelano: ACK cb0e375 Tree-SHA512: e5ab0e297143ba57513ed370c7e1227200ae454d7232c6302bf0fe6e0194e790e3f241bdeea256ceddd0ae1b808d67c4b45a8e9de2bf2d035f35bca1c31e964b
2 parents 4d85120 + cb0e375 commit 8156fd8

12 files changed

+66
-8
lines changed

compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ services:
1313
- TORRUST_INDEX_DATABASE=${TORRUST_INDEX_DATABASE:-e2e_testing_sqlite3}
1414
- TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_INDEX_DATABASE_DRIVER:-sqlite3}
1515
- TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN=${TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN:-MyAccessToken}
16-
- TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY=${TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY:-MaxVerstappenWC2021}
16+
- TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER=${TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER:-MaxVerstappenWC2021}
1717
networks:
1818
- server_side
1919
ports:

contrib/dev-tools/container/e2e/sqlite/mode/private/e2e-env-up.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ USER_ID=${USER_ID:-1000} \
88
TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \
99
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
1010
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \
11-
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY="MaxVerstappenWC2021" \
11+
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER="MaxVerstappenWC2021" \
1212
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.private.e2e.container.sqlite3.toml) \
1313
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \
1414
TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER="sqlite3" \

contrib/dev-tools/container/e2e/sqlite/mode/public/e2e-env-up.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ USER_ID=${USER_ID:-1000} \
88
TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \
99
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
1010
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \
11-
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY="MaxVerstappenWC2021" \
11+
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER="MaxVerstappenWC2021" \
1212
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.public.e2e.container.sqlite3.toml) \
1313
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \
1414
TORRUST_TRACKER_CONFIG_OVERRIDE_CORE__DATABASE__DRIVER="sqlite3" \

share/default/config/index.container.mysql.toml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ threshold = "info"
1111
#threshold = "debug"
1212
#threshold = "trace"
1313

14+
[tracker]
15+
token = "MyAccessToken"
16+
17+
[auth]
18+
user_claim_token_pepper = "MaxVerstappenWC2021"
19+
1420
[database]
1521
connect_url = "mysql://root:root_secret_password@mysql:3306/torrust_index"
1622

share/default/config/index.container.sqlite3.toml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ threshold = "info"
1111
#threshold = "debug"
1212
#threshold = "trace"
1313

14+
[tracker]
15+
token = "MyAccessToken"
16+
17+
[auth]
18+
user_claim_token_pepper = "MaxVerstappenWC2021"
19+
1420
[database]
1521
connect_url = "sqlite:///var/lib/torrust/index/database/sqlite3.db?mode=rwc"
1622

share/default/config/index.development.sqlite3.toml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ threshold = "info"
1111
#threshold = "debug"
1212
#threshold = "trace"
1313

14+
[tracker]
15+
token = "MyAccessToken"
16+
17+
[auth]
18+
user_claim_token_pepper = "MaxVerstappenWC2021"
19+
1420
# Uncomment if you want to enable TSL for development
1521
#[net.tsl]
1622
#ssl_cert_path = "./storage/index/lib/tls/localhost.crt"

share/default/config/index.private.e2e.container.sqlite3.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ threshold = "info"
1515
api_url = "http://tracker:1212"
1616
listed = false
1717
private = true
18+
token = "MyAccessToken"
1819
url = "http://tracker:7070"
1920

21+
[auth]
22+
user_claim_token_pepper = "MaxVerstappenWC2021"
23+
2024
[database]
2125
connect_url = "sqlite:///var/lib/torrust/index/database/e2e_testing_sqlite3.db?mode=rwc"
2226

@@ -25,4 +29,4 @@ port = 1025
2529
server = "mailcatcher"
2630

2731
[registration]
28-
[registration.email]
32+
[registration.email]

share/default/config/index.public.e2e.container.mysql.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ threshold = "info"
1313

1414
[tracker]
1515
api_url = "http://tracker:1212"
16+
token = "MyAccessToken"
1617
url = "udp://tracker:6969"
1718

19+
[auth]
20+
user_claim_token_pepper = "MaxVerstappenWC2021"
21+
1822
[database]
1923
connect_url = "mysql://root:root_secret_password@mysql:3306/torrust_index_e2e_testing"
2024

@@ -23,4 +27,4 @@ port = 1025
2327
server = "mailcatcher"
2428

2529
[registration]
26-
[registration.email]
30+
[registration.email]

share/default/config/index.public.e2e.container.sqlite3.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ threshold = "info"
1313

1414
[tracker]
1515
api_url = "http://tracker:1212"
16+
token = "MyAccessToken"
1617
url = "udp://tracker:6969"
1718

19+
[auth]
20+
user_claim_token_pepper = "MaxVerstappenWC2021"
21+
1822
[database]
1923
connect_url = "sqlite:///var/lib/torrust/index/database/e2e_testing_sqlite3.db?mode=rwc"
2024

@@ -23,4 +27,4 @@ port = 1025
2327
server = "mailcatcher"
2428

2529
[registration]
26-
[registration.email]
30+
[registration.email]

share/default/config/tracker.private.e2e.container.sqlite3.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ schema_version = "2.0.0"
44
[logging]
55
threshold = "info"
66

7+
[tracker]
8+
token = "MyAccessToken"
9+
10+
[auth]
11+
user_claim_token_pepper = "MaxVerstappenWC2021"
12+
713
[core]
814
listed = false
915
private = true
@@ -17,4 +23,3 @@ bind_address = "0.0.0.0:6969"
1723

1824
[http_api]
1925
bind_address = "0.0.0.0:1212"
20-

share/default/config/tracker.public.e2e.container.sqlite3.toml

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ schema_version = "2.0.0"
44
[logging]
55
threshold = "info"
66

7+
[tracker]
8+
token = "MyAccessToken"
9+
10+
[auth]
11+
user_claim_token_pepper = "MaxVerstappenWC2021"
12+
713
[core]
814
listed = false
915
private = false

src/config/mod.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,12 @@ impl Configuration {
340340
/// Will return an error if a mandatory configuration option is only
341341
/// obtained by default value (code), meaning the user hasn't overridden it.
342342
fn check_mandatory_options(figment: &Figment) -> Result<(), Error> {
343-
let mandatory_options = ["metadata.schema_version", "logging.threshold"];
343+
let mandatory_options = [
344+
"auth.user_claim_token_pepper",
345+
"logging.threshold",
346+
"metadata.schema_version",
347+
"tracker.token",
348+
];
344349

345350
for mandatory_option in mandatory_options {
346351
figment
@@ -512,6 +517,12 @@ mod tests {
512517
513518
[logging]
514519
threshold = "info"
520+
521+
[tracker]
522+
token = "MyAccessToken"
523+
524+
[auth]
525+
user_claim_token_pepper = "MaxVerstappenWC2021"
515526
"#,
516527
)?;
517528

@@ -537,6 +548,12 @@ mod tests {
537548
538549
[logging]
539550
threshold = "info"
551+
552+
[tracker]
553+
token = "MyAccessToken"
554+
555+
[auth]
556+
user_claim_token_pepper = "MaxVerstappenWC2021"
540557
"#
541558
.to_string();
542559

0 commit comments

Comments
 (0)