summaryrefslogtreecommitdiffstats
path: root/nixos/tests/google-oslogin/server.nix
blob: cd63056781789e5b87d6f6aee6adc0230d912173 (plain)
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
{ pkgs, ... }:
let
  inherit (import ./../ssh-keys.nix pkgs)
    snakeOilPrivateKey
    snakeOilPublicKey
    ;
in
{
  networking.firewall.allowedTCPPorts = [ 80 ];

  systemd.services.mock-google-metadata = {
    description = "Mock Google metadata service";
    serviceConfig.Type = "simple";
    serviceConfig.ExecStart = "${pkgs.python3}/bin/python ${./server.py}";
    environment = {
      SNAKEOIL_PUBLIC_KEY = snakeOilPublicKey;
    };
    wantedBy = [ "multi-user.target" ];
    after = [ "network.target" ];
  };

  services.openssh.enable = true;
  services.openssh.settings.KbdInteractiveAuthentication = false;
  services.openssh.settings.PasswordAuthentication = false;

  security.googleOsLogin.enable = true;

  # Mock google service
  networking.interfaces.lo.ipv4.addresses = [
    {
      address = "169.254.169.254";
      prefixLength = 32;
    }
  ];
}