1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: prepare sentinel for webapp oauth2 authentication

This commit is contained in:
oddlama 2023-06-21 01:36:44 +02:00
parent 19acca7cba
commit 6b81ecd961
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
9 changed files with 145 additions and 68 deletions

View file

@ -26,27 +26,9 @@ in {
age.secrets.loki-basic-auth-hashes = {
rekeyFile = ./secrets/loki-basic-auth-hashes.age;
generator = {
# Dependencies are added by the nodes that define passwords (using distributed-config).
script = {
pkgs,
lib,
decrypt,
deps,
...
}:
lib.flip lib.concatMapStrings deps ({
name,
host,
file,
}: ''
echo " -> Aggregating "${lib.escapeShellArg host}":"${lib.escapeShellArg name}"" >&2
echo -n ${lib.escapeShellArg host}"+"${lib.escapeShellArg name}" "
${decrypt} ${lib.escapeShellArg file} \
| ${pkgs.caddy}/bin/caddy hash-password --algorithm bcrypt \
|| die "Failure while aggregating caddy basic auth hashes"
'');
};
# Copy only the script so the dependencies can be added by the nodes
# that define passwords (using distributed-config).
generator.script = config.age.generators.basic-auth.script;
mode = "440";
group = "caddy";
};
@ -55,6 +37,7 @@ in {
useACMEHost = sentinelCfg.lib.extra.matchingWildcardCert lokiDomain;
extraConfig = ''
import common
skip_log
basicauth {
import ${sentinelCfg.age.secrets.loki-basic-auth-hashes.path}
}