Skip to content

Commit ea1e06f

Browse files
authored
Merge pull request #48 from dminuoso/add-rac-outpost
Add RAC outpost
2 parents 3082a94 + e31ed43 commit ea1e06f

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

components/gopkgs.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@
55
buildGo124Module,
66
lib,
77
makeWrapper,
8+
guacamole-server,
9+
stdenv,
810
}:
911

12+
let
13+
guacamoleAvailable = lib.meta.availableOn stdenv.hostPlatform guacamole-server;
14+
in
1015
buildGo124Module {
1116
pname = "authentik-gopkgs";
1217
version = authentik-version;
1318
prePatch = ''
1419
sed -i"" -e 's,./web/dist/,${authentikComponents.frontend}/dist/,' web/static.go
1520
sed -i"" -e 's,./web/dist/,${authentikComponents.frontend}/dist/,' internal/web/static.go
1621
sed -i"" -e 's,./lifecycle/gunicorn.conf.py,${authentikComponents.staticWorkdirDeps}/lifecycle/gunicorn.conf.py,' internal/gounicorn/gounicorn.go
22+
'' + lib.optionalString guacamoleAvailable ''
23+
substituteInPlace internal/outpost/rac/guacd.go \
24+
--replace-fail '/opt/guacamole/sbin/guacd' \
25+
"${lib.getExe guacamole-server}"
1726
'';
1827
src = lib.cleanSourceWith {
1928
src = authentik-src;
@@ -41,12 +50,16 @@ buildGo124Module {
4150
"ldap"
4251
"proxy"
4352
"radius"
53+
] ++ lib.optionals guacamoleAvailable [
54+
"rac"
4455
];
4556
subPackages = [
4657
"cmd/ldap"
4758
"cmd/server"
4859
"cmd/proxy"
4960
"cmd/radius"
61+
] ++ lib.optionals guacamoleAvailable [
62+
"cmd/rac"
5063
];
5164
vendorHash = "sha256-wTTEDBRYCW1UFaeX49ufLT0c17sacJzcCaW/8cPNYR4=";
5265
nativeBuildInputs = [ makeWrapper ];
@@ -59,5 +72,8 @@ buildGo124Module {
5972
mv $out/bin/ldap $ldap/bin/
6073
mv $out/bin/proxy $proxy/bin/
6174
mv $out/bin/radius $radius/bin/
75+
'' + lib.optionalString guacamoleAvailable ''
76+
mkdir -p $rac/bin
77+
mv $out/bin/rac $rac/bin/
6278
'';
6379
}

module.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,29 @@ in
204204
};
205205
};
206206

207+
# RAC oupost
208+
authentik-rac = {
209+
enable = mkEnableOption "authentik RAC outpost";
210+
211+
environmentFile = mkOption {
212+
type = types.nullOr pathToSecret;
213+
default = null;
214+
example = "/run/secrets/authentik-rac/authentik-rac-env";
215+
description = ''
216+
Environment file as defined in {manpage}`systemd.exec(5)`.
217+
218+
Secrets may be passed to the service without adding them to the world-readable
219+
/nix/store, by specifying the desied secrets as environment variables according
220+
to the authentic documentation.
221+
222+
```
223+
# example content
224+
AUTHENTIK_TOKEN=<token from authentik for this outpost>
225+
```
226+
'';
227+
};
228+
};
229+
207230
# RADIUS oupost
208231
authentik-radius = {
209232
enable = mkEnableOption "authentik RADIUS outpost";
@@ -497,6 +520,40 @@ in
497520
}
498521
))
499522

523+
# RAC outpost
524+
(mkIf config.services.authentik-rac.enable (
525+
let
526+
cfg = config.services.authentik-rac;
527+
in
528+
{
529+
assertions = [
530+
{
531+
assertion = config.services.authentik.authentikComponents.gopkgs?rac;
532+
message = ''
533+
guacamole-server is not available on the host's platform!
534+
'';
535+
}
536+
];
537+
systemd.services.authentik-rac = {
538+
wantedBy = [ "multi-user.target" ];
539+
wants = [ "network-online.target" ];
540+
after = [
541+
"network-online.target"
542+
"authentik.service"
543+
];
544+
serviceConfig = {
545+
RuntimeDirectory = "authentik-rac";
546+
UMask = "0027";
547+
WorkingDirectory = "%t/authentik-rac";
548+
DynamicUser = true;
549+
ExecStart = "${config.services.authentik.authentikComponents.gopkgs.rac}/bin/rac";
550+
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
551+
Restart = "on-failure";
552+
};
553+
};
554+
}
555+
))
556+
500557
# RADIUS outpost
501558
(mkIf config.services.authentik-radius.enable (
502559
let

0 commit comments

Comments
 (0)