diff options
author | MS <ms@taler.net> | 2021-05-25 10:28:37 +0200 |
---|---|---|
committer | MS <ms@taler.net> | 2021-05-25 10:28:37 +0200 |
commit | a7733762799b7df2e83a3dca8141ab9eba0244f8 (patch) | |
tree | 3b8006de194f59c5cbd064a49b13b79381be9cd7 /bin/taler-deployment-config-instances | |
parent | b8b676c09e47eb2b706c3bd59a2f59a838301161 (diff) | |
download | deployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.tar.gz deployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.tar.bz2 deployment-a7733762799b7df2e83a3dca8141ab9eba0244f8.zip |
include Authorization header
Diffstat (limited to 'bin/taler-deployment-config-instances')
-rwxr-xr-x | bin/taler-deployment-config-instances | 14 |
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}'") |