From 90683369be019254c2b86bfc4ca3c8de3b441ff0 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 21 Oct 2015 09:11:01 +0200 Subject: m 3 bepasty-server: fix escape --- makefu/3modules/bepasty-server.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'makefu/3modules') diff --git a/makefu/3modules/bepasty-server.nix b/makefu/3modules/bepasty-server.nix index d970652a..bc7158d8 100644 --- a/makefu/3modules/bepasty-server.nix +++ b/makefu/3modules/bepasty-server.nix @@ -104,12 +104,12 @@ let PrivateTmp = true; ExecStartPre = pkgs.writeScript "bepasty-server.${name}-init" '' #!/bin/sh - chmod 755 ${server.workDir} - mkdir -p ${server.dataDir} + chmod 755 "${server.workDir}" + mkdir -p "${server.dataDir}" cat > ${server.workDir}/bepasty-${name}.conf < Date: Wed, 21 Oct 2015 17:13:12 +0200 Subject: m 3 tinc_graphs: new api for nginx --- makefu/3modules/tinc_graphs.nix | 51 ++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'makefu/3modules') diff --git a/makefu/3modules/tinc_graphs.nix b/makefu/3modules/tinc_graphs.nix index ff2f5587..42b08d62 100644 --- a/makefu/3modules/tinc_graphs.nix +++ b/makefu/3modules/tinc_graphs.nix @@ -20,26 +20,37 @@ let default = "${pkgs.geolite-legacy}/share/GeoIP/GeoIPCity.dat"; }; - krebsNginx = { - # configure krebs nginx to serve the new graphs - enable = mkEnableOption "tinc_graphs nginx"; + nginx = { + enable = mkEnableOption "enable tinc_graphs to be served with nginx"; + + anonymous = { + server-names = mkOption { + type = with types; listOf str; + description = "hostnames which serve anonymous graphs"; + default = [ "graphs.${config.krebs.build.host.name}" ]; + }; + + listen = mkOption { + type = with types; listOf str; + description = "listen address for anonymous graphs"; + default = [ "80" ]; + }; - hostnames_complete = mkOption { - #TODO: this is not a secure way to serve these graphs,better listen to - # the correct interface, krebs.nginx does not support this yet - - type = with types; listOf str; - description = "hostname which serves complete graphs"; - default = [ "graphs.${config.krebs.build.host.name}" ]; }; - hostnames_anonymous = mkOption { - type = with types; listOf str; - description = '' - hostname which serves anonymous graphs - must be different from hostname_complete - ''; - default = [ "anongraphs.${config.krebs.build.host.name}" ]; + complete = { + server-names = mkOption { + type = with types; listOf str; + description = "hostname which serves complete graphs"; + default = [ "graphs.${config.krebs.build.host.name}" ]; + }; + + listen = mkOption { + type = with types; listOf str; + description = "listen address for complete graphs"; + default = [ "127.0.0.1:80" ]; + }; + }; }; @@ -110,8 +121,7 @@ let }; krebs.nginx.servers = mkIf cfg.krebsNginx.enable { - tinc_graphs_complete = { - server-names = cfg.krebsNginx.hostnames_complete; + tinc_graphs_complete = cfg.nginx.complete { locations = [ (nameValuePair "/" '' autoindex on; @@ -119,8 +129,7 @@ let '') ]; }; - tinc_graphs_anonymous = { - server-names = cfg.krebsNginx.hostnames_anonymous; + tinc_graphs_anonymous = cfg.nginx.anonymous // { locations = [ (nameValuePair "/" '' autoindex on; -- cgit v1.2.3 From 49b8d341f64b039448a21feeaed777573574549d Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 21 Oct 2015 18:47:26 +0200 Subject: m 3 tinc_graphs: merge instead of override nginx config --- makefu/3modules/tinc_graphs.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'makefu/3modules') diff --git a/makefu/3modules/tinc_graphs.nix b/makefu/3modules/tinc_graphs.nix index 42b08d62..1f87f00c 100644 --- a/makefu/3modules/tinc_graphs.nix +++ b/makefu/3modules/tinc_graphs.nix @@ -31,6 +31,7 @@ let }; listen = mkOption { + # use the type of the nginx listen option type = with types; listOf str; description = "listen address for anonymous graphs"; default = [ "80" ]; @@ -120,23 +121,23 @@ let createHome = true; }; - krebs.nginx.servers = mkIf cfg.krebsNginx.enable { - tinc_graphs_complete = cfg.nginx.complete { + krebs.nginx.servers = mkIf cfg.nginx.enable { + tinc_graphs_complete = mkMerge [ cfg.nginx.complete { locations = [ (nameValuePair "/" '' autoindex on; root ${internal_dir}; '') ]; - }; - tinc_graphs_anonymous = cfg.nginx.anonymous // { + }] ; + tinc_graphs_anonymous = mkMerge [ cfg.nginx.anonymous { locations = [ (nameValuePair "/" '' autoindex on; root ${external_dir}; '') ]; - }; + }]; }; }; -- cgit v1.2.3 From 34fd2ceb299d55b5edff124f86adf0883101197c Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 21 Oct 2015 18:48:13 +0200 Subject: m 3 bepasty-server: finishing touches --- makefu/3modules/bepasty-server.nix | 48 +++++++++++++++++++++----------------- makefu/3modules/default.nix | 1 + 2 files changed, 27 insertions(+), 22 deletions(-) (limited to 'makefu/3modules') diff --git a/makefu/3modules/bepasty-server.nix b/makefu/3modules/bepasty-server.nix index bc7158d8..ff32eea6 100644 --- a/makefu/3modules/bepasty-server.nix +++ b/makefu/3modules/bepasty-server.nix @@ -6,10 +6,10 @@ let bepasty = pkgs.pythonPackages.bepasty-server; gevent = pkgs.pythonPackages.gevent; python = pkgs.pythonPackages.python; - cfg = config.makefu.bepasty-server; + cfg = config.krebs.bepasty; out = { - options.makefu.bepasty-server = api; + options.krebs.bepasty = api; config = mkIf cfg.enable (mkMerge [(mkIf cfg.serveNginx nginx-imp) imp ]) ; }; @@ -20,27 +20,20 @@ let servers = mkOption { type = with types; attrsOf optionSet; options = singleton { - nginxCfg = mkOption { + nginx = mkOption { # TODO use the correct type type = with types; attrsOf unspecified; description = '' additional nginx configuration. see krebs.nginx for all options '' ; }; - debug = mkOption { - type = types.bool; - description = '' - run server in debug mode - ''; - default = false; - }; - # TODO: assert secretKey secretKey = mkOption { type = types.str; description = '' server secret for safe session cookies, must be set. ''; + default = ""; }; # we create a wsgi socket in $workDir/gunicorn-${name}.wsgi @@ -66,6 +59,7 @@ let extraConfig = mkOption { type = types.str; default = ""; + # TODO configure permissions in separate example = '' PERMISSIONS = { 'myadminsecret': 'admin,list,create,read,delete', @@ -75,8 +69,13 @@ let }; defaultPermissions = mkOption { + # TODO: listOf str type = types.str; - default = "list"; + description = '' + default permissions for all unauthenticated users. + ''; + example = "read,create,delete"; + default = "read"; }; }; @@ -102,21 +101,22 @@ let serviceConfig = { Type = "simple"; PrivateTmp = true; - ExecStartPre = pkgs.writeScript "bepasty-server.${name}-init" '' + + ExecStartPre = assert server.secretKey != ""; pkgs.writeScript "bepasty-server.${name}-init" '' #!/bin/sh - chmod 755 "${server.workDir}" - mkdir -p "${server.dataDir}" - cat > ${server.workDir}/bepasty-${name}.conf < "${server.workDir}/bepasty-${name}.conf" <