From e853576ca26825273acf7b7cf92a9a43b6b47be7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 21 Jul 2022 09:37:37 +0200 Subject: apply access control override logic also to /instances/default path --- src/backend/taler-merchant-httpd.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/backend/taler-merchant-httpd.c') diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 94213556..43e945b2 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -241,15 +241,7 @@ TMH_instance_decref (struct TMH_MerchantInstance *mi) } -/** - * Callback that frees an instances removing - * it from the global hashmap. - * - * @param cls closure, NULL - * @param key current key - * @param value a `struct TMH_MerchantInstance` - */ -int +enum GNUNET_GenericReturnValue TMH_instance_free_cb (void *cls, const struct GNUNET_HashCode *key, void *value) @@ -1169,6 +1161,24 @@ url_handler (void *cls, instance_id = GNUNET_strndup (istart, slash - istart); hc->instance = TMH_lookup_instance (instance_id); + if ( (NULL == hc->instance) && + (0 == strcmp ("default", + instance_id)) ) + hc->instance = TMH_lookup_instance (NULL); + if ( (0 == strcmp ("default", + instance_id)) && + (NULL != TMH_default_auth) && + (NULL != hc->instance) ) + { + /* Override default instance access control */ + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Overriding access control\n"); + TMH_compute_auth (TMH_default_auth, + &hc->instance->auth.auth_salt, + &hc->instance->auth.auth_hash); + hc->instance->auth_override = true; + GNUNET_free (TMH_default_auth); + } GNUNET_free (instance_id); if (NULL == slash) url = ""; -- cgit v1.2.3