diff --git a/cmd/wg-portal/main.go b/cmd/wg-portal/main.go index 9a24566..456290c 100644 --- a/cmd/wg-portal/main.go +++ b/cmd/wg-portal/main.go @@ -9,6 +9,7 @@ import ( "github.com/go-playground/validator/v10" evbus "github.com/vardius/message-bus" + "gorm.io/gorm/schema" "github.com/h44z/wg-portal/internal" "github.com/h44z/wg-portal/internal/adapters" @@ -41,6 +42,8 @@ func main() { cfg.LogStartupValues() + dbEncryptedSerializer := app.NewGormEncryptedStringSerializer(cfg.Database.EncryptionPassphrase) + schema.RegisterSerializer("encstr", dbEncryptedSerializer) rawDb, err := adapters.NewDatabase(cfg.Database) internal.AssertNoError(err) diff --git a/docs/documentation/configuration/examples.md b/docs/documentation/configuration/examples.md index 5912e34..46e7ed1 100644 --- a/docs/documentation/configuration/examples.md +++ b/docs/documentation/configuration/examples.md @@ -31,6 +31,7 @@ database: debug: true type: sqlite dsn: data/sqlite.db + encryption_passphrase: change-this-s3cr3t-encryption-passphrase ``` ## LDAP Authentication and Synchronization diff --git a/docs/documentation/configuration/overview.md b/docs/documentation/configuration/overview.md index a155696..ca75637 100644 --- a/docs/documentation/configuration/overview.md +++ b/docs/documentation/configuration/overview.md @@ -214,6 +214,8 @@ Additional or more specialized configuration options for logging and interface c Configuration for the underlying database used by WireGuard Portal. Supported databases include SQLite, MySQL, Microsoft SQL Server, and Postgres. +If sensitive values (like private keys) should be stored in an encrypted format, set the `encryption_passphrase` option. + ### `debug` - **Default:** `false` - **Description:** If `true`, logs all database statements (verbose). @@ -234,6 +236,12 @@ Supported databases include SQLite, MySQL, Microsoft SQL Server, and Postgres. user:pass@tcp(1.2.3.4:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local ``` +### `encryption_passphrase` +- **Default:** *(empty)* +- **Description:** Passphrase for encrypting sensitive values such as private keys in the database. Encryption is only applied if this passphrase is set. + **Important:** Once you enable encryption by setting this passphrase, you cannot disable it or change it afterward. + New or updated records will be encrypted; existing data remains in plaintext until it’s next modified. + --- ## Statistics diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 6e1aa81..53a4b7c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -85,6 +85,9 @@ const currentYear = ref(new Date().getFullYear()) +