Skip to content

Commit

Permalink
wip: dex
Browse files Browse the repository at this point in the history
  • Loading branch information
jakehamilton committed Oct 16, 2022
1 parent 33d028d commit df729dc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions modules/services/dex/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,15 @@ in
after = [ "networking.target" ];

preStart = ''
if ! test -d "${cfg.stateDir}"; then
mkdir -p "${cfg.stateDir}"
chmod -R 600 "${cfg.stateDir}"
fi
cp --remove-destination ${configYaml} ${cfg.stateDir}/config.yaml
"${pkgs.coreutils}/bin/install -m 600 ${configYaml} ${cfg.stateDir}/config.yaml"
chmod 600 ${cfg.stateDir}/config.yaml
${replace-config-secrets}
'';

serviceConfig = {
ExecStart = "${pkgs.dex-oidc}/bin/dex serve /run/dex/config.yaml";
ExecStart = "${pkgs.dex-oidc}/bin/dex serve ${cfg.stateDir}/config.yaml";
WorkingDirectory = cfg.stateDir;

User = cfg.user;
Expand Down
21 changes: 11 additions & 10 deletions modules/services/tailscale-authproxy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in
tcpAddress = mkOpt str "" "The address to listen on";
socketPath = mkOpt str "" "The unix socket file to listen on";

restrictTailnet = mkOpt (either [ str null ]) null "Only allow access from a single Tailnet";
restrictTailnet = mkOpt (nullOr str) null "Only allow access from a single Tailnet";

allowUnauthorized = mkOpt bool false "Whether or not to allow unauthorized machines";
dexCallbackUrl = mkOpt str "http://127.0.0.1/dex/callback/tailscale-authproxy" "The url to use for authenticating with Dex";
Expand All @@ -40,7 +40,7 @@ in
partOf = [ "tailscale-authproxy.service" ];

socketConfig = {
ListenStream = "/var/run/tailscale-authproxy.sock";
ListenStream = "/run/tailscale-authproxy.sock";
};
};

Expand All @@ -52,17 +52,18 @@ in
Type = "simple";
User = cfg.user;
Group = cfg.group;
Restart = "always";
RestartSec = 20;

# Restart = "always";
# RestartSec = 20;

ExecStart =
let
args = [
"-listen-type=systemd"
"-dex-callback-url='${cfg.dexCallbackUrl}'"
] ++ optional (cfg.allowUnauthorized) "-allow-unauthorized"
++ optional (cfg.restrictTailnet != null) "-restrict-tailnet='${cfg.restrictTailnet}'";
args =
[ "-listen-type=systemd" "-dex-callback-url='${cfg.dexCallbackUrl}'" ]
++ optional (cfg.allowUnauthorized) "-allow-unauthorized"
++ optional (cfg.restrictTailnet != null) "-restrict-tailnet='${cfg.restrictTailnet}'";
in
"${pkgs.tailscale-authproxy} -listen-type=systemd -dex-callback-url='${cfg.dexCallbackUrl}'";
"${pkgs.tailscale-authproxy}/bin/tailscale-authproxy ${concatStringsSep " " args}'";
};
};
};
Expand Down

0 comments on commit df729dc

Please sign in to comment.