summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMS <ms@taler.net>2021-05-25 10:28:37 +0200
committerMS <ms@taler.net>2021-05-25 10:28:37 +0200
commita7733762799b7df2e83a3dca8141ab9eba0244f8 (patch)
tree3b8006de194f59c5cbd064a49b13b79381be9cd7
parentb8b676c09e47eb2b706c3bd59a2f59a838301161 (diff)
downloaddeployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.tar.gz
deployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.tar.bz2
deployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.zip
include Authorization header
-rwxr-xr-xbin/taler-deployment-config-instances14
1 files changed, 10 insertions, 4 deletions
diff --git a/bin/taler-deployment-config-instances b/bin/taler-deployment-config-instances
index cff8316..c7dec85 100755
--- a/bin/taler-deployment-config-instances
+++ b/bin/taler-deployment-config-instances
@@ -25,11 +25,12 @@ MERCHANT_BACKEND_BASE_URL = expect_env("TALER_ENV_MERCHANT_BACKEND")
TALER_ENV_NAME = expect_env("TALER_ENV_NAME")
TALER_CONFIG_CURRENCY = expect_env("TALER_CONFIG_CURRENCY")
TALER_ENV_FRONTENDS_APITOKEN = expect_env("TALER_ENV_FRONTENDS_APITOKEN")
-
+authotization_header = {"Authorization": f"Bearer {TALER_ENV_FRONTENDS_APITOKEN}"}
def ensure_instance(instance_id, name, payto_uris, auth):
# FIXME: Use auth once the default instance also uses token auth
instance_response = requests.get(
- urljoin(MERCHANT_BACKEND_BASE_URL, f"private/instances/${instance_id}")
+ urljoin(MERCHANT_BACKEND_BASE_URL, f"private/instances/${instance_id}"),
+ headers = authorization_header
)
if instance_response.status_code == 200:
return
@@ -47,15 +48,20 @@ def ensure_instance(instance_id, name, payto_uris, auth):
# FIXME: Eventually, this should be an actual secret token
auth=auth,
)
+ # Here authenticats as 'default' (with same credentials of other instances.)
create_resp = requests.post(
- urljoin(MERCHANT_BACKEND_BASE_URL, "private/instances"), json=req
+ urljoin(MERCHANT_BACKEND_BASE_URL, "private/instances"),
+ json=req,
+ headers = authorization_header
)
if create_resp.status_code < 200 or create_resp.status_code >= 300:
print(f"Instance '{instance_id}' could not be (re)created, backend says: {create_resp.text}. Updating its auth now")
if instance_id != "Tutorial":
patch_resp = requests.post(
urljoin(MERCHANT_BACKEND_BASE_URL,
- f"instances/{instance_id}/private/auth"), json=auth
+ f"instances/{instance_id}/private/auth"),
+ json=auth,
+ headers = authorization_header
)
if patch_resp.status_code < 200 or patch_resp.status_code >= 300:
print(f"Failed to update auth of '{instance_id}'")