nixos-config/hosts/plover/modules/services/vouch-proxy.nix

62 lines
1.7 KiB
Nix
Raw Normal View History

2023-10-07 19:28:14 +00:00
{ config, lib, pkgs, ... }:
let
inherit (config.services.vouch-proxy.instances."${vouchDomain}") settings;
2023-10-07 19:28:14 +00:00
vouchDomain = "vouch.${config.networking.domain}";
authDomain = config.services.kanidm.serverSettings.domain;
in
{
sops.secrets = lib.getSecrets ../../secrets/secrets.yaml {
"vouch-proxy/jwt/secret" = { };
"vouch-proxy/client/secret" = { };
};
services.vouch-proxy = {
enable = true;
instances."${vouchDomain}".settings = {
2023-10-07 19:28:14 +00:00
vouch = {
listen = "127.0.0.1";
port = 19900;
domains = [ "foodogsquared.one" ];
jwt.secret._secret = config.sops.secrets."vouch-proxy/jwt/secret".path;
};
oauth = rec {
provider = "oidc";
client_id = "vouch";
2023-10-07 19:28:14 +00:00
client_secret._secret = config.sops.secrets."vouch-proxy/client/secret".path;
code_challenge_method = "S256";
2023-10-07 19:28:14 +00:00
auth_url = "${authDomain}/ui/oauth2";
token_url = "${authDomain}/oauth2/token";
user_info_url = "${authDomain}/oauth2/openid/${client_id}/userinfo";
scopes = [ "login" "email" ];
2023-10-07 19:28:14 +00:00
callback_url = "https://${vouchDomain}/auth";
};
};
};
services.nginx.virtualHosts."${vouchDomain}" = {
forceSSL = true;
enableACME = true;
acmeRoot = null;
kTLS = true;
locations."/" = {
proxyPass = "http://vouch-proxy";
2023-10-07 19:28:14 +00:00
extraConfig = ''
proxy_set_header Host ${vouchDomain};
proxy_set_header X-Forwarded-Proto https;
'';
};
};
services.nginx.upstreams."vouch-proxy" = {
extraConfig = ''
zone apps;
'';
servers = {
"${settings.vouch.listen}:${builtins.toString settings.vouch.port}" = { };
};
};
2023-10-07 19:28:14 +00:00
}