summaryrefslogtreecommitdiff
path: root/docker/demo
diff options
context:
space:
mode:
authorMS <ms@taler.net>2022-11-15 21:30:29 +0100
committerMS <ms@taler.net>2022-11-15 21:30:29 +0100
commitd9667202ae292f5796567193ef9666ba800015a9 (patch)
tree93cf0589002db3f3a6ade72f42cdec0d9e03afea /docker/demo
parentd3f99366f69ad2fc8ec9e729008bb312debf01d7 (diff)
downloaddeployment-d9667202ae292f5796567193ef9666ba800015a9.tar.gz
deployment-d9667202ae292f5796567193ef9666ba800015a9.tar.bz2
deployment-d9667202ae292f5796567193ef9666ba800015a9.zip
use token auth
Diffstat (limited to 'docker/demo')
-rw-r--r--docker/demo/config/deployment.conf2
-rw-r--r--docker/demo/images/merchant/Dockerfile1
-rw-r--r--docker/demo/images/merchant/create_instances.sh15
-rw-r--r--docker/demo/images/merchant/startup.sh29
-rw-r--r--docker/demo/images/merchant/update_instances_auth.sh18
-rwxr-xr-xdocker/demo/test-docker-localhost.sh (renamed from docker/demo/test-docker-mvp.sh)3
6 files changed, 54 insertions, 14 deletions
diff --git a/docker/demo/config/deployment.conf b/docker/demo/config/deployment.conf
index aed9a06..113e0f0 100644
--- a/docker/demo/config/deployment.conf
+++ b/docker/demo/config/deployment.conf
@@ -1,6 +1,6 @@
[taler-deployment]
currency = EUR
-merchant-apikey = secret
+merchant-apikey = secret-token:salt
merchant-url = http://localhost:5556/
exchange-nexus-username = exchange-at-nexus
exchange-nexus-password = secret-at-nexus
diff --git a/docker/demo/images/merchant/Dockerfile b/docker/demo/images/merchant/Dockerfile
index 4121177..7618081 100644
--- a/docker/demo/images/merchant/Dockerfile
+++ b/docker/demo/images/merchant/Dockerfile
@@ -3,5 +3,6 @@ FROM taler_local/taler_base
COPY taler.conf /config/taler.conf
COPY startup.sh /
COPY create_instances.sh /
+COPY update_instances_auth.sh /
RUN chmod +x /startup.sh
ENTRYPOINT /startup.sh
diff --git a/docker/demo/images/merchant/create_instances.sh b/docker/demo/images/merchant/create_instances.sh
index 4053d90..6c0a3b7 100644
--- a/docker/demo/images/merchant/create_instances.sh
+++ b/docker/demo/images/merchant/create_instances.sh
@@ -1,21 +1,22 @@
echo -n "Create default instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$DEFAULT_IBAN'?receiver-name=Merchant43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token","token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$DEFAULT_IBAN'?receiver-name=Merchant43"],"id":"default","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
echo -n "Create pos instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$POS_IBAN'?receiver-name=PoS"],"id":"pos","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$POS_IBAN'?receiver-name=PoS"],"id":"pos","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
echo -n "Create blog instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$BLOG_IBAN'?receiver-name=BlogCompany"],"id":"blog","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$BLOG_IBAN'?receiver-name=BlogCompany"],"id":"blog","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
+
echo -n "Create GNUnet instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$GNUNET_IBAN'?receiver-name=GNUnet"],"id":"GNUnet","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$GNUNET_IBAN'?receiver-name=GNUnet"],"id":"GNUnet","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
echo -n "Create Taler instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$TALER_IBAN'?receiver-name=GNUnet"],"id":"Taler","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$TALER_IBAN'?receiver-name=GNUnet"],"id":"Taler","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
echo -n "Create Tor instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$TOR_IBAN'?receiver-name=GNUnet"],"id":"Tor","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$TOR_IBAN'?receiver-name=GNUnet"],"id":"Tor","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
echo -n "Create survey instance..."
-curl -s -H "Content-Type: application/json" -X POST -d '{"auth":{"method":"external"},"payto_uris":["payto://iban/SANDBOXX/'$SURVEY_IBAN'?receiver-name=GNUnet"],"id":"survey","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"auth":{"method":"token", "token":"'$BACKEND_APIKEY'"},"payto_uris":["payto://iban/SANDBOXX/'$SURVEY_IBAN'?receiver-name=GNUnet"],"id":"survey","name":"default","address":{},"jurisdiction":{},"default_max_wire_fee":"'${CURRENCY}':1", "default_max_deposit_fee":"'${CURRENCY}':1","default_wire_fee_amortization":1,"default_wire_transfer_delay":{"d_us" : 1000000},"default_pay_delay":{"d_us": 3600000000}}' http://merchant/management/instances
echo DONE
diff --git a/docker/demo/images/merchant/startup.sh b/docker/demo/images/merchant/startup.sh
index 90548f0..690680b 100644
--- a/docker/demo/images/merchant/startup.sh
+++ b/docker/demo/images/merchant/startup.sh
@@ -89,15 +89,35 @@ echo "Init database... "
taler-merchant-dbinit -L DEBUG -c /config/taler.conf
echo DONE
echo -n "Launch merchant backend..."
-taler-merchant-httpd -c /config/taler.conf 2>&1 | \
+taler-merchant-httpd -a $BACKEND_APIKEY -c /config/taler.conf 2>&1 | \
rotatelogs -e /logs/taler-merchant-httpd-%Y-%m-%d 86400 &
echo DONE
sleep 1
is_serving "${BACKEND_URL}config"
-source /create_instances.sh
-
+# If the witness instance exists or has wrong auth,
+# then all the others do.
+echo -n "Checking instances existence..."
+INSTANCES_STATUS=$(curl -s -o /dev/null \
+ -w "%{http_code}" \
+ -H "Authorization: Bearer $BACKEND_APIKEY" \
+ "${BACKEND_URL}instances/Taler/private")
+echo "DONE ($INSTANCES_STATUS)"
+
+case $INSTANCES_STATUS in
+ "404")
+ echo "Taler (witness) instance not found, assuming none is."
+ source /create_instances.sh;
+ ;;
+ "401")
+ echo "Taler (witness) instance had wrong auth, assuming API key is new."
+ source /update_instances_auth.sh;
+ ;;
+ *)
+ echo Default instance found, API key correct, do nothing.
+ ;;
+esac
export TALER_ENV_URL_MERCHANT_BLOG=`taler-config -c /config/deployment.conf -s taler-deployment -o blog-url`
export TALER_ENV_URL_MERCHANT_DONATIONS=`taler-config -c /config/deployment.conf -s taler-deployment -o donations-url`
export TALER_ENV_URL_MERCHANT_SURVEY=`taler-config -c /config/deployment.conf -s taler-deployment -o survey-url`
@@ -118,13 +138,12 @@ ${HOME}/.local/bin/taler-merchant-demos -c /config/taler.conf --http-port 8083 l
echo DONE
echo -n Creating a reserve for tips...
-
PAYTO_RESERVE=$(
taler-merchant-setup-reserve \
--amount ${CURRENCY}:20 \
--exchange-url ${EXCHANGE_URL} \
--merchant-url http://localhost/instances/survey/ \
- --apikey "Bearer {BACKEND_APIKEY}" \
+ --apikey "Bearer ${BACKEND_APIKEY}" \
--wire-method iban
)
diff --git a/docker/demo/images/merchant/update_instances_auth.sh b/docker/demo/images/merchant/update_instances_auth.sh
new file mode 100644
index 0000000..b1ab8a6
--- /dev/null
+++ b/docker/demo/images/merchant/update_instances_auth.sh
@@ -0,0 +1,18 @@
+echo -n "Change pos auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/pos/auth
+echo DONE
+echo -n "Change blog auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/blog/auth
+echo DONE
+echo -n "Change GNUnet auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/GNUnet/auth
+echo DONE
+echo -n "Change Taler auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/Taler/auth
+echo DONE
+echo -n "Change Tor auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/Tor/auth
+echo DONE
+echo -n "Change survey auth..."
+curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $BACKEND_APIKEY" -X POST -d '{"method":"token", "token":"'$BACKEND_APIKEY'"}' http://merchant/management/instances/survey/auth
+echo DONE
diff --git a/docker/demo/test-docker-mvp.sh b/docker/demo/test-docker-localhost.sh
index f8b9763..234d840 100755
--- a/docker/demo/test-docker-mvp.sh
+++ b/docker/demo/test-docker-localhost.sh
@@ -5,5 +5,6 @@ taler-wallet-cli --no-throttle api --expect-success 'runIntegrationTest' \
"amountToWithdraw":"EUR:30",
"bankBaseUrl":"http://localhost:15000/demobanks/default/access-api/",
"exchangeBaseUrl":"http://localhost:5555/",
- "merchantBaseUrl":"http://localhost:5556/"
+ "merchantBaseUrl":"http://localhost:5556/",
+ "merchantAuthToken": "'${TALER_DOCKER_APIKEY:-secret-token:salt}'"
}'