about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/security/shibboleth-sp.nix
blob: 975de1efa2f2a3be99919a0c7c5553e0aeb2e0c4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{ config, lib, pkgs, ... }:

let
  cfg = config.services.shibboleth-sp;
in {
  options = {
    services.shibboleth-sp = {
      enable = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = lib.mdDoc "Whether to enable the shibboleth service";
      };

      configFile = lib.mkOption {
        type = lib.types.path;
        example = lib.literalExpression ''"''${pkgs.shibboleth-sp}/etc/shibboleth/shibboleth2.xml"'';
        description = lib.mdDoc "Path to shibboleth config file";
      };

      fastcgi.enable = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description = lib.mdDoc "Whether to include the shibauthorizer and shibresponder FastCGI processes";
      };

      fastcgi.shibAuthorizerPort = lib.mkOption {
        type = lib.types.int;
        default = 9100;
        description = lib.mdDoc "Port for shibauthorizer FastCGI process to bind to";
      };

      fastcgi.shibResponderPort = lib.mkOption {
        type = lib.types.int;
        default = 9101;
        description = lib.mdDoc "Port for shibauthorizer FastCGI process to bind to";
      };
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.shibboleth-sp = {
      description = "Provides SSO and federation for web applications";
      after       = lib.optionals cfg.fastcgi.enable [ "shibresponder.service" "shibauthorizer.service" ];
      wantedBy    = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${pkgs.shibboleth-sp}/bin/shibd -F -d ${pkgs.shibboleth-sp} -c ${cfg.configFile}";
      };
    };

    systemd.services.shibresponder = lib.mkIf cfg.fastcgi.enable {
      description = "Provides SSO through Shibboleth via FastCGI";
      after       = [ "network.target" ];
      wantedBy    = [ "multi-user.target" ];
      path    	  = [ "${pkgs.spawn_fcgi}" ];
      environment.SHIBSP_CONFIG = "${cfg.configFile}";
      serviceConfig = {
        ExecStart = "${pkgs.spawn_fcgi}/bin/spawn-fcgi -n -p ${toString cfg.fastcgi.shibResponderPort} ${pkgs.shibboleth-sp}/lib/shibboleth/shibresponder";
      };
    };

    systemd.services.shibauthorizer = lib.mkIf cfg.fastcgi.enable {
      description = "Provides SSO through Shibboleth via FastCGI";
      after       = [ "network.target" ];
      wantedBy    = [ "multi-user.target" ];
      path    	  = [ "${pkgs.spawn_fcgi}" ];
      environment.SHIBSP_CONFIG = "${cfg.configFile}";
      serviceConfig = {
        ExecStart = "${pkgs.spawn_fcgi}/bin/spawn-fcgi -n -p ${toString cfg.fastcgi.shibAuthorizerPort} ${pkgs.shibboleth-sp}/lib/shibboleth/shibauthorizer";
      };
    };
  };

  meta.maintainers = with lib.maintainers; [ ];
}