Skip to content

Commit 0ed564c

Browse files
committed
Merge #1692: Document MySQL DSN password URL-encoding requirement
bcbef65 docs(configuration): document MySQL DSN password URL-encoding (Jose Celano) Pull request description: ## Summary Document that MySQL DSN passwords must be percent-encoded when they contain reserved URL characters. ## Changes - Add URL-encoding guidance to container deployment docs. - Add URL-encoding note to the default MySQL tracker config example. - Clarify MySQL DSN format in configuration docs and add encoding requirement for reserved characters. ## Why Deployments commonly build DSNs from environment variables. Generated secrets can include characters like `+` and `/`, which break DSN parsing unless encoded. Fixes #1606 ACKs for top commit: josecelano: ACK bcbef65 Tree-SHA512: f00a4f16e5796ba4963fa7d939235cb9f7b108349b4455056abfef6c793d3d375fad4d4349a0839c68b6adcba89f6d21ebd730684d1b69678224f59f7e08f752
2 parents d178b2b + bcbef65 commit 0ed564c

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

docs/containers.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ driver = "mysql"
248248
path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker"
249249
```
250250

251+
Important: if the MySQL password contains reserved URL characters (for example `+`, `/`, `@`, or `:`), it must be percent-encoded in the DSN password component. For example, if the raw password is `a+b/c`, use `a%2Bb%2Fc` in the DSN.
252+
253+
When generating secrets automatically, prefer URL-safe passwords (`A-Z`, `a-z`, `0-9`, `-`, `_`) to avoid DSN parsing issues.
254+
251255
### Build and Run:
252256

253257
```sh
@@ -292,7 +296,7 @@ These are some useful commands for MySQL.
292296
Open a shell in the MySQL container using docker or docker-compose.
293297

294298
```s
295-
docker exec -it torrust-mysql-1 /bin/bash
299+
docker exec -it torrust-mysql-1 /bin/bash
296300
docker compose exec mysql /bin/bash
297301
```
298302

packages/configuration/src/v2_0_0/database.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ pub struct Database {
1212
/// Database connection string. The format depends on the database driver.
1313
/// For `sqlite3`, the format is `path/to/database.db`, for example:
1414
/// `./storage/tracker/lib/database/sqlite3.db`.
15-
/// For `Mysql`, the format is `mysql://db_user:db_user_password:port/db_name`, for
15+
/// For `mysql`, the format is `mysql://db_user:db_user_password@host:port/db_name`, for
1616
/// example: `mysql://root:password@localhost:3306/torrust`.
17+
/// If the password contains reserved URL characters (for example `+` or `/`),
18+
/// percent-encode it in the URL.
1719
#[serde(default = "Database::default_path")]
1820
pub path: String,
1921
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ private = false
1212

1313
[core.database]
1414
driver = "mysql"
15+
# If the MySQL password includes reserved URL characters (for example + or /),
16+
# percent-encode it in the DSN password component.
17+
# Example: password a+b/c -> a%2Bb%2Fc
1518
path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker"
1619

1720
# Uncomment to enable services

0 commit comments

Comments
 (0)