kanidm auth
This commit is contained in:
parent
63c7ca4ee8
commit
fe3cc33ed3
1 changed files with 273 additions and 81 deletions
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue