merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit e853576ca26825273acf7b7cf92a9a43b6b47be7
parent 6ea6a9ae8ed3535bddb8c11b15dc9ebc6f68aec1
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Thu, 21 Jul 2022 09:37:37 +0200

apply access control override logic also to /instances/default path

Diffstat:
Msrc/backend/taler-merchant-httpd.c | 28+++++++++++++++++++---------
Msrc/backend/taler-merchant-httpd.h | 7++++---
2 files changed, 23 insertions(+), 12 deletions(-)

diff --git 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 = ""; diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h @@ -626,11 +626,12 @@ extern char *TMH_default_auth; * Callback that frees an instances removing * it from the global hashmap. * - * @param cls closure, NULL - * @param key current key + * @param cls closure, pass NULL + * @param key current key (ignored) * @param value a `struct TMH_MerchantInstance` + * @return #GNUNET_YES (always) */ -int +enum GNUNET_GenericReturnValue TMH_instance_free_cb (void *cls, const struct GNUNET_HashCode *key, void *value);