gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-deployment] branch master updated: preferring loading API token f


From: gnunet
Subject: [taler-deployment] branch master updated: preferring loading API token from file
Date: Mon, 17 May 2021 16:33:18 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository deployment.

The following commit(s) were added to refs/heads/master by this push:
     new b0ff994  preferring loading API token from file
b0ff994 is described below

commit b0ff994f0303709320d8c210ec64b984f21ac092
Author: MS <ms@taler.net>
AuthorDate: Mon May 17 16:33:11 2021 +0200

    preferring loading API token from file
---
 bin/taler-deployment            | 17 +++++++++++------
 bin/taler-deployment-auth-token | 31 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/bin/taler-deployment b/bin/taler-deployment
index 62924cb..398a2b8 100755
--- a/bin/taler-deployment
+++ b/bin/taler-deployment
@@ -28,7 +28,6 @@ from typing import List, Callable
 from shutil import copy
 from taler_urls import get_urls
 from string import ascii_letters, ascii_uppercase
-import random
 
 activate_template = """\
 #!/bin/bash
@@ -571,6 +570,12 @@ allowed_envs = (
     "tanker"
 )
 
+def load_apitoken():
+    apitoken_path = Path.home() / "envcfg.py"
+    if not os.path.isfile(apitoken_path):
+        return None
+    with open(apitoken_path, "r") as f:
+        return f.readline()
 
 def load_envcfg():
     cfg = types.ModuleType("taler_deployment_cfg")
@@ -657,9 +662,6 @@ def sync_repos() -> None:
         r_dir = home / "sources" / r.name
         subprocess.run(["git", "-C", str(r_dir), "clean", "-fdx"], check=True)
 
-def generate_apitoken():
-    return "secret-token:" + ''.join(random.choices(ascii_letters + 
ascii_uppercase, k=10))
-
 @cli.command()
 def bootstrap() -> None:
     """Bootstrap a GNU Taler deployment."""
@@ -681,7 +683,10 @@ def bootstrap() -> None:
         path_list.insert(0, local_path)
     if deployment_path not in path_list:
         path_list.insert(0, deployment_path)
-
+    apitoken = load_apitoken()
+    if not apitoken:
+        print("Please create ~/merchant_auth_token 
(taler-deployment-auth-token can help).")
+        return 1
     with (home / "activate").open("w") as f:
         f.write(
             activate_template.format(
@@ -690,7 +695,7 @@ def bootstrap() -> None:
                 currency=currmap[envname],
                 curr_path=":".join(path_list),
                 coverage=1 if envname == "coverage" else 0,
-                frontends_apitoken="{}".format(generate_apitoken()),
+                frontends_apitoken="{}".format(apitoken),
                 **get_urls(envname)
             )
         )
diff --git a/bin/taler-deployment-auth-token b/bin/taler-deployment-auth-token
new file mode 100644
index 0000000..bd638fd
--- /dev/null
+++ b/bin/taler-deployment-auth-token
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+
+# This file is part of GNU Taler.
+#
+# GNU Taler is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GNU Taler is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Taler.  If not, see <https://www.gnu.org/licenses/>.
+
+import random
+import os
+
+TOKEN_FILE = "~/merchant_auth_token"
+
+def generate_apitoken():
+    return "secret-token:" + ''.join(random.choices(ascii_letters + 
ascii_uppercase, k=10))
+
+if os.path.isfile(TOKEN_FILE):
+    print("~/merchant_auth_token exists already.  Not overwriting it!")
+    return 0
+
+with open(TOKEN_FILE) as f:
+    f.write(generate_apitoken())

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]