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-post-instances.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-post-instances.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-post-instances.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 1cd1a0bb..79c78f38 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -142,9 +142,13 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, { struct TALER_MERCHANTDB_InstanceSettings is; json_t *payto_uris; + const char *auth_token = NULL; 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 ("id", @@ -205,6 +209,14 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, is.id)) && (0 == strcmp (mi->settings.name, is.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, @@ -343,6 +355,21 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, } } + 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); + } { struct TMH_MerchantInstance *mi; enum GNUNET_DB_QueryStatus qs; |