18 cfg = config.services.tailscaleAuth;
21 options.services.tailscaleAuth = {
22 enable = mkEnableOption "tailscale.nginx-auth, to authenticate users via tailscale";
24 package = mkPackageOption pkgs "tailscale-nginx-auth" { };
28 default = "tailscale-nginx-auth";
29 description = "User which runs tailscale-nginx-auth";
34 default = "tailscale-nginx-auth";
35 description = "Group which runs tailscale-nginx-auth";
38 socketPath = mkOption {
39 default = "/run/tailscale-nginx-auth/tailscale-nginx-auth.sock";
42 Path of the socket listening to authorization requests.
47 config = mkIf cfg.enable {
48 services.tailscale.enable = true;
50 users.users.${cfg.user} = {
54 users.groups.${cfg.group} = { };
56 systemd.sockets.tailscale-nginx-auth = {
57 description = "Tailscale NGINX Authentication socket";
58 partOf = [ "tailscale-nginx-auth.service" ];
59 wantedBy = [ "sockets.target" ];
60 listenStreams = [ cfg.socketPath ];
63 SocketUser = cfg.user;
64 SocketGroup = cfg.group;
68 systemd.services.tailscale-nginx-auth = {
69 description = "Tailscale NGINX Authentication service";
70 requires = [ "tailscale-nginx-auth.socket" ];
73 ExecStart = getExe cfg.package;
74 RuntimeDirectory = "tailscale-nginx-auth";
78 BindPaths = [ "/run/tailscale/tailscaled.sock" ];
80 CapabilityBoundingSet = "";
82 LockPersonality = true;
83 MemoryDenyWriteExecute = true;
84 PrivateDevices = true;
87 ProtectControlGroups = true;
89 ProtectHostname = true;
90 ProtectKernelLogs = true;
91 ProtectKernelModules = true;
92 ProtectKernelTunables = true;
93 RestrictNamespaces = true;
94 RestrictAddressFamilies = [ "AF_UNIX" ];
95 RestrictRealtime = true;
96 RestrictSUIDSGID = true;
98 SystemCallArchitectures = "native";
99 SystemCallErrorNumber = "EPERM";
114 meta.maintainers = with maintainers; [