diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-31 13:12:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-31 13:12:04 +0100 |
commit | 83f0cd871092dcd547eee18c2b67ec10ac1828ff (patch) | |
tree | b0a9fe84a727fbe55c630a7fa4c3e09c2f8497b2 /src/backend/taler-merchant-httpd_private-patch-instances-ID.c | |
parent | 9dded1aec4e5e62dce29ac86bc486112c7bff60d (diff) | |
download | merchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.tar.gz merchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.tar.bz2 merchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.zip |
implement import of auth_token into merchant DB when configuring instances (#6731)
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-patch-instances-ID.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-patch-instances-ID.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c index 755e6f02..4590e6c5 100644 --- a/src/backend/taler-merchant-httpd_private-patch-instances-ID.c +++ b/src/backend/taler-merchant-httpd_private-patch-instances-ID.c @@ -63,10 +63,14 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, struct TMH_MerchantInstance *mi = hc->instance; struct TALER_MERCHANTDB_InstanceSettings is; json_t *payto_uris; + const char *auth_token = NULL; const char *name; struct TMH_WireMethod *wm_head = NULL; struct TMH_WireMethod *wm_tail = NULL; struct GNUNET_JSON_Specification spec[] = { + GNUNET_JSON_spec_mark_optional ( + GNUNET_JSON_spec_string ("auth_token", + &auth_token)), GNUNET_JSON_spec_json ("payto_uris", &payto_uris), GNUNET_JSON_spec_string ("name", @@ -145,6 +149,14 @@ TMH_private_patch_instances_ID (const struct TMH_RequestHandler *rh, /* Check for equality of settings */ if (! ( (0 == strcmp (mi->settings.name, name)) && + ( ( (NULL != auth_token) && + (GNUNET_OK == + TMH_check_auth (auth_token, + &mi->settings.auth_salt, + &mi->settings.auth_hash)) ) || + ( (NULL == auth_token) && + (GNUNET_YES == + GNUNET_is_zero (&mi->settings.auth_hash))) ) && (1 == json_equal (mi->settings.address, is.address)) && (1 == json_equal (mi->settings.jurisdiction, @@ -356,6 +368,21 @@ giveup: json_decref (mi->settings.address); json_decref (mi->settings.jurisdiction); is.id = mi->settings.id; + if (NULL == auth_token) + { + memset (&is.auth_salt, + 0, + sizeof (is.auth_salt)); + memset (&is.auth_hash, + 0, + sizeof (is.auth_hash)); + } + else + { + TMH_compute_auth (auth_token, + &is.auth_salt, + &is.auth_hash); + } mi->settings = is; mi->settings.address = json_incref (mi->settings.address); mi->settings.jurisdiction = json_incref (mi->settings.jurisdiction); |