From 3e710e61d2f879b5b54ddbd09595078286e4bf0e Mon Sep 17 00:00:00 2001 From: Inex Code Date: Tue, 16 Nov 2021 13:28:16 +0300 Subject: [PATCH] Add api token param --- api/api-module.nix | 7 +++++++ api/api.nix | 3 ++- userdata/schema.json | 8 ++++++++ variables-module.nix | 8 ++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/api/api-module.nix b/api/api-module.nix index 5c9998a..dfedebd 100644 --- a/api/api-module.nix +++ b/api/api-module.nix @@ -19,6 +19,12 @@ in Enable SelfPrivacy API service ''; }; + token = mkOption { + type = types.string; + description = '' + SelfPrivacy API token + ''; + }; }; config = lib.mkIf cfg.enable { @@ -28,6 +34,7 @@ in inherit (config.environment.sessionVariables) NIX_PATH; HOME = "/root"; PYTHONUNBUFFERED = "1"; + AUTH_TOKEN = cfg.token; } // config.networking.proxy.envVars; path = [ "/var/" "/var/dkim/" pkgs.coreutils pkgs.gnutar pkgs.xz.bin pkgs.gzip pkgs.gitMinimal config.nix.package.out pkgs.nixos-rebuild pkgs.restic pkgs.mkpasswd ]; after = [ "network-online.target" ]; diff --git a/api/api.nix b/api/api.nix index 37875d4..72391a6 100644 --- a/api/api.nix +++ b/api/api.nix @@ -1,7 +1,8 @@ -{ pkgs, ... }: +{ config, pkgs, ... }: { services.selfprivacy-api = { enable = true; + token = config.services.userdata.api.token; }; users.users."selfprivacy-api" = { diff --git a/userdata/schema.json b/userdata/schema.json index c49ae6f..f7de2d1 100644 --- a/userdata/schema.json +++ b/userdata/schema.json @@ -18,6 +18,14 @@ "timezone": { "type": "string" }, + "api": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, "backblaze": { "type": "object", "properties": { diff --git a/variables-module.nix b/variables-module.nix index 54c31bf..f9651de 100644 --- a/variables-module.nix +++ b/variables-module.nix @@ -37,6 +37,14 @@ in ''; type = types.nullOr types.string; }; + api = { + token = mkOption { + description = '' + API token used to authenticate with the server + ''; + type = types.nullOr types.string; + }; + }; backblaze = { bucket = mkOption { description = "Bucket name used for userdata backups";