summary refs log tree commit diff
path: root/nixos/modules/services/security/hologram.nix
blob: f9abf38942f43713efebe94f22210776df18a8b2 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{pkgs, config, lib, ...}:

with lib;

let
  cfg = config.services.hologram-server;

  cfgFile = pkgs.writeText "hologram-server.json" (builtins.toJSON {
    ldap = {
      host = cfg.ldapHost;
      bind = {
        dn       = cfg.ldapBindDN;
        password = cfg.ldapBindPassword;
      };
      insecureldap = cfg.ldapInsecure;
      userattr     = cfg.ldapUserAttr;
      baseDN       = cfg.ldapBaseDN;
    };
    aws = {
      account     = cfg.awsAccount;
      defaultrole = cfg.awsDefaultRole;
    };
    stats  = cfg.statsAddress;
    listen = cfg.listenAddress;
  });
in {
  options = {
    services.hologram-server = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Whether to enable the Hologram server for AWS instance credentials";
      };

      listenAddress = mkOption {
        type        = types.str;
        default     = "0.0.0.0:3100";
        description = "Address and port to listen on";
      };

      ldapHost = mkOption {
        type        = types.str;
        description = "Address of the LDAP server to use";
      };

      ldapInsecure = mkOption {
        type        = types.bool;
        default     = false;
        description = "Whether to connect to LDAP over SSL or not";
      };

      ldapUserAttr = mkOption {
        type        = types.str;
        default     = "cn";
        description = "The LDAP attribute for usernames";
      };

      ldapBaseDN = mkOption {
        type        = types.str;
        description = "The base DN for your Hologram users";
      };

      ldapBindDN = mkOption {
        type        = types.str;
        description = "DN of account to use to query the LDAP server";
      };

      ldapBindPassword = mkOption {
        type        = types.str;
        description = "Password of account to use to query the LDAP server";
      };

      awsAccount = mkOption {
        type        = types.str;
        description = "AWS account number";
      };

      awsDefaultRole = mkOption {
        type        = types.str;
        description = "AWS default role";
      };

      statsAddress = mkOption {
        type        = types.str;
        default     = "";
        description = "Address of statsd server";
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.services.hologram-server = {
      description = "Provide EC2 instance credentials to machines outside of EC2";
      after       = [ "network.target" ];
      wantedBy    = [ "multi-user.target" ];

      serviceConfig = {
        ExecStart = "${pkgs.goPackages.hologram}/bin/hologram-server --debug --conf ${cfgFile}";
      };
    };
  };
}