@@ -0,0 +1,71 @@
1+{pkgs, config, lib, ...}:
2+
3+with lib;
4+let
5+ cfg = config.services.shibboleth-sp;
6+in {
7+ options = {
8+ services.shibboleth-sp = {
9+ enable = mkOption {
10+ type = types.bool;
11+ default = false;
12+ description = "Whether to enable the shibboleth service";
13+ };
14+
15+ configFile = mkOption {
16+ type = types.path;
17+ example = "${pkgs.shibboleth-sp}/etc/shibboleth/shibboleth2.xml";
18+ description = "Path to shibboleth config file";
19+ };
20+
21+ fastcgi.enable = mkOption {
22+ type = types.bool;
23+ default = false;
24+ description = "Whether to include the shibauthorizer and shibresponder FastCGI processes";
25+ };
26+
27+ fastcgi.shibAuthorizerPort = mkOption {
28+ type = types.int;
29+ default = 9100;
30+ description = "Port for shibauthorizer FastCGI proccess to bind to";
31+ };
32+
33+ fastcgi.shibResponderPort = mkOption {
34+ type = types.int;
35+ default = 9101;
36+ description = "Port for shibauthorizer FastCGI proccess to bind to";
37+ };
38+ };
39+ };
40+
41+ config = mkIf cfg.enable {
42+ systemd.services.shibboleth-sp = {
43+ description = "Provides SSO and federation for web applications";
44+ after = lib.optionals cfg.fastcgi.enable [ "shibresponder.service" "shibauthorizer.service" ];
45+ wantedBy = [ "multi-user.target" ];
46+ serviceConfig = {
47+ ExecStart = "${pkgs.shibboleth-sp}/bin/shibd -F -d ${pkgs.shibboleth-sp} -c ${cfg.configFile}";
48+ };
49+ };
50+
51+ systemd.services.shibresponder = mkIf cfg.fastcgi.enable {
52+ description = "Provides SSO through Shibboleth via FastCGI";
53+ after = [ "network.target" ];
54+ wantedBy = [ "multi-user.target" ];
55+ path = [ "${pkgs.spawn_fcgi}" ];
56+ serviceConfig = {
57+ ExecStart = "${pkgs.spawn_fcgi}/bin/spawn-fcgi -n -p ${toString cfg.fastcgi.shibResponderPort} ${pkgs.shibboleth-sp}/lib/shibboleth/shibresponder";
58+ };
59+ };
60+
61+ systemd.services.shibauthorizer = mkIf cfg.fastcgi.enable {
62+ description = "Provides SSO through Shibboleth via FastCGI";
63+ after = [ "network.target" ];
64+ wantedBy = [ "multi-user.target" ];
65+ path = [ "${pkgs.spawn_fcgi}" ];
66+ serviceConfig = {
67+ ExecStart = "${pkgs.spawn_fcgi}/bin/spawn-fcgi -n -p ${toString cfg.fastcgi.shibAuthorizerPort} ${pkgs.shibboleth-sp}/lib/shibboleth/shibauthorizer";
68+ };
69+ };
70+ };
71+}