From ac77bfab9840fc86e6d260881097bf3027846e09 Mon Sep 17 00:00:00 2001 From: Dave Kempe Date: Tue, 10 Mar 2026 11:44:34 +1100 Subject: [PATCH] v0.6.1: Vault mTLS support, comprehensive test suite (87 tests) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vault/OpenBao mTLS: - Add ca_cert, client_cert, client_key fields to [vault] config - Supports custom CA certificates and mutual TLS authentication - Clear error messages for missing files, invalid PEM, missing key - Fixes #48 (OpenBao requiring client certificates) Test suite (8 → 87 tests): - vault: 13 tests (TLS client builder, config deserialization, name validation) - auth: 11 tests (role hierarchy, effective role capping, XFF/trusted proxy, has_role) - session: 12 tests (CIDR network checks, autofill JSON parsing, placeholder substitution) - browser: 8 tests (Chromium password encryption, Login Data SQLite, RangeAllocator) - config: 8 tests (preset resolution, theme overrides, defaults, vault config) - api: 6 tests (HTML escaping, recording name path traversal protection) - db: 7 tests (SHA-256 hashing, key generation, user groups parsing) - import: 12 tests (already existed, now wired into module tree) - protocol: 8 tests (already existed) Other: - Wire import.rs into module tree (fixes orphaned tests) - Document mTLS config in configuration.md and integrations.md Co-Authored-By: Claude Opus 4.6 --- Cargo.lock | 2 +- Cargo.toml | 2 +- docs/configuration.md | 4 + docs/integrations.md | 29 +++++ src/api.rs | 60 ++++++++++ src/auth.rs | 101 +++++++++++++++++ src/browser.rs | 110 ++++++++++++++++++ src/config.rs | 91 +++++++++++++++ src/db.rs | 80 ++++++++++++++ src/import.rs | 41 +++++-- src/main.rs | 1 + src/session.rs | 109 ++++++++++++++++++ src/vault.rs | 252 +++++++++++++++++++++++++++++++++++++++++- 13 files changed, 868 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 242c5e7..179c210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3015,7 +3015,7 @@ dependencies = [ [[package]] name = "rustguac" -version = "0.6.0" +version = "0.6.1" dependencies = [ "aes", "axum", diff --git a/Cargo.toml b/Cargo.toml index 35be8ea..c1fbc3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustguac" -version = "0.6.0" +version = "0.6.1" edition = "2021" description = "Lightweight Rust replacement for Apache Guacamole client" diff --git a/docs/configuration.md b/docs/configuration.md index 1ca536d..c279df8 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -95,6 +95,10 @@ Enables the Vault-backed address book. Requires `VAULT_SECRET_ID` environment va | `base_path` | `rustguac` | Base path under the mount | | `namespace` | — | Vault Enterprise / OpenBao namespace | | `instance_name` | — | Instance name for instance-scoped entries | +| `tls_skip_verify` | `false` | Skip TLS certificate verification (dev only) | +| `ca_cert` | — | Path to custom CA certificate (PEM) for verifying the Vault server | +| `client_cert` | — | Path to client certificate (PEM) for mTLS | +| `client_key` | — | Path to client private key (PEM) for mTLS (required if `client_cert` is set) | ## `[drive]` section diff --git a/docs/integrations.md b/docs/integrations.md index b515f21..4e2f2df 100644 --- a/docs/integrations.md +++ b/docs/integrations.md @@ -174,6 +174,35 @@ echo 'VAULT_SECRET_ID=' > /opt/rustguac/env chmod 600 /opt/rustguac/env ``` +### mTLS (client certificate authentication) + +If your Vault or OpenBao server requires mutual TLS (client certificates), add the certificate paths to the `[vault]` section: + +```toml +[vault] +addr = "https://openbao.example.com:8200" +role_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" +ca_cert = "/opt/rustguac/certs/vault-ca.pem" +client_cert = "/opt/rustguac/certs/vault-client.pem" +client_key = "/opt/rustguac/certs/vault-client-key.pem" +``` + +| Field | Description | +|-------|-------------| +| `ca_cert` | Custom CA certificate (PEM) for verifying the Vault server. Use this when Vault uses a private or self-signed CA. | +| `client_cert` | Client certificate (PEM) presented to Vault for mTLS. | +| `client_key` | Client private key (PEM). Required when `client_cert` is set. | + +Ensure the certificate files are readable by the `rustguac` system user and have restrictive permissions: + +```bash +mkdir -p /opt/rustguac/certs +cp ca.pem client.pem client-key.pem /opt/rustguac/certs/ +chown rustguac:rustguac /opt/rustguac/certs/* +chmod 600 /opt/rustguac/certs/client-key.pem +chmod 644 /opt/rustguac/certs/ca.pem /opt/rustguac/certs/client.pem +``` + ### KV v2 path structure | Path | Description | diff --git a/src/api.rs b/src/api.rs index dc7faaa..933e964 100644 --- a/src/api.rs +++ b/src/api.rs @@ -2500,3 +2500,63 @@ fn html_escape(s: &str) -> String { .replace('"', """) .replace('\'', "'") } + +#[cfg(test)] +mod tests { + use super::*; + use std::path::Path; + + #[test] + fn test_html_escape_special_chars() { + assert_eq!(html_escape("