kanidm auth

This commit is contained in:
Henry Hiles 2026-11-15 10:44:28 -05:00
commit fe3cc33ed3
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -1,15 +1,5 @@
{ lib, ... }:
{
config,
pkgs,
lib,
...
}:
{
options.services.caddy.authedHosts = lib.mkOption {
type = lib.types.attrsOf lib.types.lines;
default = { };
};
config = {
systemd = {
services = {
@ -48,42 +38,11 @@
services.caddy = {
enable = true;
email = "henry@henryhiles.com";
environmentFile = config.age.secrets."base64JwtSecret.age".path;
package = pkgs.caddy.withPlugins {
plugins = [
"github.com/ggicci/caddy-jwt@v1.3.0"
];
hash = "sha256-35MdO6F5hZ/0tUAnMWwMfMy/4yPBNuMzHZP3SBlxz+8=";
};
globalConfig = ''
metrics {
per_host
}
'';
virtualHosts = lib.mapAttrs (domain: host: {
extraConfig =
let
auth = "https://auth.federated.nexus";
in
''
handle_errors 401 {
redir https://federated.nexus/login?redirect_uri=${auth}/bridge?redirect_uri=https://${domain}{uri} 302
}
route {
jwtauth {
from_cookies id_token
sign_key {$JWK_SECRET}
issuer_whitelist ${auth}
audience_whitelist proxy
}
${host}
}
'';
}) config.services.caddy.authedHosts;
};
};
}