From 6ed6093ddb305897037abaa5b25dcd9cc6b9bc60 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Mon, 29 Jun 2026 00:11:45 -0500 Subject: [PATCH] feat(authelia): secure user database via sops-nix templates This commit removes the static users.yml file and transitions Authelia identity management to a fully encrypted, declarative SOPS template. - Mount /run/secrets/users.yml as a read-only volume in Authelia - Add documentation for generating secure Argon2id password hashes - Update setup_guide.md with the sops-nix template for declarative users --- docker-compose.yml | 1 + docs/setup_guide.md | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5c9bf24..43252a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -101,6 +101,7 @@ services: restart: always volumes: - ./config/authelia:/config + - /run/secrets/users.yml:/config/users.yml:ro environment: - DOMAIN=${DOMAIN} - AUTHELIA_SESSION_SECRET=${AUTHELIA_SESSION_SECRET} diff --git a/docs/setup_guide.md b/docs/setup_guide.md index 9fe0c14..ee1df95 100644 --- a/docs/setup_guide.md +++ b/docs/setup_guide.md @@ -37,7 +37,7 @@ Secrets are managed declaratively using **`sops-nix`** (Mozilla SOPS + age keys) ## 🔑 Adding/Editing Secrets -To add or modify credentials (e.g. changing your Dynu API key or regenerating Authelia secrets): +To add or modify credentials (e.g. changing your Dynu API key or updating Authelia users): 1. Navigate to your system configuration repository: ```bash @@ -54,7 +54,12 @@ To add or modify credentials (e.g. changing your Dynu API key or regenerating Au authelia_session_secret: "secure_64_character_hex_string" authelia_storage_encryption_key: "secure_64_character_hex_string" authelia_identity_validation_reset_password_jwt_secret: "secure_64_character_hex_string" + + # Hashed password for the default admin user + authelia_user_kiskaadee_password_hash: "$argon2id$v=19$m=65536..." ``` + *To generate an Argon2 password hash securely, run:* + `docker run --rm -it authelia/authelia:latest authelia crypto hash generate argon2` 4. Save and close the editor. SOPS will automatically encrypt the file and write it back to disk. --- @@ -78,9 +83,26 @@ sops.templates."homeserver.env" = { AUTHELIA_IDENTITY_VALIDATION_RESET_PASSWORD_JWT_SECRET = config.sops.placeholder.authelia_identity_validation_reset_password_jwt_secret; }; }; + +# 2. Declarative User Database Template +We also generate Authelia's `users.yml` file from the decrypted Argon2 hash: +```nix +sops.templates."users.yml" = { + owner = "kiskaadee"; + content = '' + users: + kiskaadee: + displayname: "Kiskaadee" + password: "${config.sops.placeholder.authelia_user_kiskaadee_password_hash}" + email: "fcortesbio@gmail.com" + groups: + - admins + - dev + ''; +}; ``` -### 2. systemd Lifecycle Daemon +### 3. systemd Lifecycle Daemon The service starts and stops the compose stack automatically: ```nix systemd.services.homeserver-core = {