WIP: Firefly-iii. Missing auth with Authentik

This commit is contained in:
pazpi 2025-05-05 22:46:49 +02:00
parent 8174cc5756
commit 952a3da61d
9 changed files with 252 additions and 0 deletions

View file

@ -55,6 +55,12 @@ in
}; };
}; };
firefly-iii.proxy = {
enable = true;
domain = p.domains.public;
host = p.hosts.firefly-iii;
};
immich.proxy = { immich.proxy = {
enable = true; enable = true;
domain = p.domains.public; domain = p.domains.public;

View file

@ -233,6 +233,16 @@ in
# specialArgs = { }; # specialArgs = { };
}; };
firefly-iii = nixpkgs.lib.nixosSystem {
pkgs = pkgs "x86_64-linux";
modules = [
myModules
proxmoxModule
./firefly-iii
agenix.nixosModules.default
];
# specialArgs = { };
};
open-webui = nixpkgs-unstable.lib.nixosSystem { open-webui = nixpkgs-unstable.lib.nixosSystem {
pkgs = pkgs-unstable "x86_64-linux"; pkgs = pkgs-unstable "x86_64-linux";
@ -255,4 +265,5 @@ in
]; ];
# specialArgs = { }; # specialArgs = { };
}; };
} }

View file

@ -34,6 +34,7 @@ in
"portainer" "portainer"
"vaultwarden" "vaultwarden"
"immich" "immich"
"firefly-iii"
"paperless" "paperless"
]; ];
}; };
@ -136,6 +137,15 @@ in
]; ];
}; };
firefly-iii.deployment = {
targetHost = hosts.firefly-iii;
tags = [
"lxc"
"bacco"
"firefly-iii"
];
};
open-webui.deployment = { open-webui.deployment = {
targetHost = hosts.open-webui; targetHost = hosts.open-webui;
tags = [ tags = [

View file

@ -0,0 +1,41 @@
{
config,
pkgs,
lib,
...
}:
{
age.secrets = {
firefly-iii-app-key = {
file = ../../secrets/firefly-iii-app-key.age;
owner = config.services.firefly-iii.user;
group = config.services.firefly-iii.group;
};
firefly-iii-mailgun-key = {
file = ../../secrets/firefly-iii-mailgun-key.age;
owner = config.services.firefly-iii.user;
group = config.services.firefly-iii.group;
};
};
my = {
utils = {
commons.enable = true;
lxc-standard.enable = true;
};
services.firefly-iii = {
enable = true;
accessToken = config.age.secrets.firefly-iii-app-key.path;
mailgun_key = config.age.secrets.firefly-iii-mailgun-key.path;
};
virtualisation.proxmox.enable = true;
};
# Extra packages
environment.systemPackages = with pkgs; [ ];
system.stateVersion = "24.11";
}

View file

@ -17,6 +17,7 @@
shadowsocks = "shadowsocks.internal"; shadowsocks = "shadowsocks.internal";
librechat = "librechat.internal"; librechat = "librechat.internal";
immich = "immich.internal"; immich = "immich.internal";
firefly-iii = "firefly-iii.internal";
open-webui = "open-webui.home"; open-webui = "open-webui.home";
paperless = "paperless.internal"; paperless = "paperless.internal";
}; };

View file

@ -2,6 +2,7 @@
imports = [ imports = [
./authentik.nix ./authentik.nix
./dashy.nix ./dashy.nix
./firefly-iii.nix
./immich.nix ./immich.nix
./media-mgr.nix ./media-mgr.nix
./nextcloud.nix ./nextcloud.nix

View file

@ -0,0 +1,179 @@
{
lib,
config,
pkgs,
...
}:
let
cfg = config.my.services.firefly-iii;
dbName = "firefly-iii";
appPort = 9080;
dataImpPort = 9081;
in
{
options.my.services.firefly-iii = {
enable = lib.mkEnableOption "Enable Firefly-III budgeting app";
accessToken = lib.mkOption {
type = lib.types.path;
default = "";
description = ''
Access token for Firefly-III
'';
};
# age.secrets.firefly-iii-mailgun-key.file = ../../secrets/firefly-iii-mailgun-key.age;
mailgun_key = lib.mkOption {
type = lib.types.path;
default = "";
description = ''
Mailgun API key for sending emails
'';
};
proxy = {
enable = lib.mkEnableOption "Set the proxy entry for this service";
domain = lib.mkOption {
default = "example.com";
type = lib.types.str;
description = ''
The domain where Caddy is reachable
'';
};
subdomain = lib.mkOption {
default = "money";
type = lib.types.str;
description = ''
The subdomain where Immich is reachable
'';
};
host = lib.mkOption {
default = "localhost";
type = lib.types.str;
description = ''
host name where the service is running
'';
};
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
my.services.postgresql = {
enable = true;
ensures = [
{
username = config.services.firefly-iii.user;
database = dbName;
}
];
};
services.firefly-iii = {
enable = true;
enableNginx = true;
settings = {
APP_ENV = "production";
APP_URL = "https://${cfg.proxy.subdomain}.${cfg.proxy.domain}";
SITE_OWNER = "davide@pasetto.me";
DEFAULT_LANGUAGE = "en_US";
TZ = "Europe/Rome";
TRUSTED_PROXIES = "**";
SEND_ERROR_MESSAGE = "true";
SEND_REPORT_JOURNALS = "false";
# AUTHENTICATION_GUARD = "web";
AUTHENTICATION_GUARD = "remote_user_guard";
AUTHENTICATION_GUARD_HEADER = "X-Authentik-Username";
AUTHENTICATION_GUARD_EMAIL = "X-Authentik-Email";
PGSQL_SCHEMA = "public";
DB_CONNECTION = "pgsql";
DB_DATABASE = dbName;
DB_USERNAME = config.services.firefly-iii.user;
MAILGUN_ENDPOINT = "api.eu.mailgun.net";
MAILGUN_DOMAIN = "pazpi.top";
MAILGUN_SECRET_FILE = cfg.mailgun_key;
# Exactly 32 chars
APP_KEY_FILE = cfg.accessToken;
};
};
services.firefly-iii-data-importer = {
enable = true;
enableNginx = true;
virtualHost = "firefly-iii-data-importer";
settings = {
FIREFLY_III_ACCESS_TOKEN = cfg.accessToken;
};
};
networking.firewall.allowedTCPPorts = [
appPort
dataImpPort
];
services.nginx.virtualHosts = {
${config.services.firefly-iii.virtualHost} = {
listen = [
{
addr = "0.0.0.0";
port = appPort;
}
];
};
${config.services.firefly-iii-data-importer.virtualHost} = {
listen = [
{
addr = "0.0.0.0";
port = dataImpPort;
}
];
};
};
})
(lib.mkIf cfg.proxy.enable {
services.caddy = with cfg.proxy; {
virtualHosts."${subdomain}.${domain}".extraConfig = ''
# directive execution order is only as stated if enclosed with route.
route {
# always forward outpost path to actual outpost
reverse_proxy /outpost.goauthentik.io/* https://auth.pasetto.me {
header_up Host {http.reverse_proxy.upstream.hostport}
}
# forward authentication to outpost
forward_auth https://auth.pasetto.me {
uri /outpost.goauthentik.io/auth/caddy
# capitalization of the headers is important, otherwise they will be empty
copy_headers X-Authentik-Username X-Authentik-Email
# optional, in this config trust all private ranges, should probably be set to the outposts IP
trusted_proxies private_ranges
}
# Firefly-III
reverse_proxy http://${host}:${toString appPort}
}
reverse_proxy http://${host}:${toString appPort}
import cloudflare_${domain}
'';
};
})
];
}

View file

@ -27,6 +27,8 @@ let
dns02-admin-password = [ machines.dns02 ]; dns02-admin-password = [ machines.dns02 ];
dns02-dhcp-failover = [ machines.dns02 ]; dns02-dhcp-failover = [ machines.dns02 ];
shadowsocks-password = [ machines.shadowsocks ]; shadowsocks-password = [ machines.shadowsocks ];
firefly-iii-app-key = [ machines.firefly-iii ];
firefly-iii-mailgun-key = [ machines.firefly-iii ];
paperless-admin = [ machines.paperless ]; paperless-admin = [ machines.paperless ];
paperless-oauth2-client-secret = [ machines.paperless ]; paperless-oauth2-client-secret = [ machines.paperless ];
}; };

View file

@ -20,6 +20,7 @@ rec {
dns01 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII7BdiP/dCE6FHoJylcBKQ5AXz06UpLHNyeuvfLVccSi"; dns01 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII7BdiP/dCE6FHoJylcBKQ5AXz06UpLHNyeuvfLVccSi";
dns02 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+HIq6/ebjiv71xDozdOTn5AdnXgr1fGqIzXnH7Not+"; dns02 = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ+HIq6/ebjiv71xDozdOTn5AdnXgr1fGqIzXnH7Not+";
shadowsocks = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINQ4qYaS5ccciH7BNyrF5+J3d4JtHJNr1R256/ulEtxl"; shadowsocks = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINQ4qYaS5ccciH7BNyrF5+J3d4JtHJNr1R256/ulEtxl";
firefly-iii = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGYkXjRqmuTMg56EmAx8s1M/VQojM7akF/ao+jJLYgFB";
paperless = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRNgDyk3TuMooG4ZCv7SOgXh0ql1/1hhhng7uSnsLeK"; paperless = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRNgDyk3TuMooG4ZCv7SOgXh0ql1/1hhhng7uSnsLeK";
}; };