From c1c40eaa24926273a6aa688e92e99d832aa1501e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 Aug 2021 11:01:38 +0200 Subject: -preparations for sepa auth plugin --- src/backend/anastasis-httpd_config.c | 6 ++---- src/backend/anastasis-httpd_truth.c | 14 ++++++++++---- src/backend/anastasis-httpd_truth_upload.c | 25 ++++++++++--------------- 3 files changed, 22 insertions(+), 23 deletions(-) (limited to 'src/backend') diff --git a/src/backend/anastasis-httpd_config.c b/src/backend/anastasis-httpd_config.c index 89b82d0..d265f99 100644 --- a/src/backend/anastasis-httpd_config.c +++ b/src/backend/anastasis-httpd_config.c @@ -40,7 +40,6 @@ add_methods (void *cls, { json_t *method_arr = cls; struct ANASTASIS_AuthorizationPlugin *p; - struct TALER_Amount cost; json_t *method; if (0 != strncasecmp (section, @@ -54,8 +53,7 @@ add_methods (void *cls, return; section += strlen ("authorization-"); p = ANASTASIS_authorization_plugin_load (section, - AH_cfg, - &cost); + AH_cfg); if (NULL == p) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -67,7 +65,7 @@ add_methods (void *cls, GNUNET_JSON_pack_string ("type", section), TALER_JSON_pack_amount ("cost", - &cost)); + &p->cost)); GNUNET_assert ( 0 == json_array_append_new (method_arr, diff --git a/src/backend/anastasis-httpd_truth.c b/src/backend/anastasis-httpd_truth.c index f69ff7b..ee0f2bf 100644 --- a/src/backend/anastasis-httpd_truth.c +++ b/src/backend/anastasis-httpd_truth.c @@ -1168,8 +1168,7 @@ AH_handler_truth_get ( { gc->authorization = ANASTASIS_authorization_plugin_load (method, - AH_cfg, - &gc->challenge_cost); + AH_cfg); if (NULL == gc->authorization) { MHD_RESULT ret; @@ -1184,6 +1183,7 @@ AH_handler_truth_get ( GNUNET_free (method); return ret; } + gc->challenge_cost = gc->authorization->cost; } else { @@ -1192,6 +1192,7 @@ AH_handler_truth_get ( GNUNET_free (method); } + if (! gc->authorization->payment_plugin_managed) { struct TALER_Amount zero_amount; @@ -1294,6 +1295,7 @@ AH_handler_truth_get ( uint64_t code; enum ANASTASIS_DB_CodeStatus cs; struct GNUNET_HashCode hc; + bool satisfied; rt = GNUNET_TIME_UNIT_FOREVER_ABS; qs = db->create_challenge_code (db->cls, @@ -1327,7 +1329,8 @@ AH_handler_truth_get ( &hc); cs = db->verify_challenge_code (db->cls, &gc->truth_uuid, - &hc); + &hc, + &satisfied); switch (cs) { case ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH: @@ -1376,12 +1379,14 @@ AH_handler_truth_get ( if (gc->have_response) { enum ANASTASIS_DB_CodeStatus cs; + bool satisfied; GNUNET_free (decrypted_truth); GNUNET_free (truth_mime); cs = db->verify_challenge_code (db->cls, &gc->truth_uuid, - &challenge_response); + &challenge_response, + &satisfied); switch (cs) { case ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH: @@ -1407,6 +1412,7 @@ AH_handler_truth_get ( TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED, NULL); case ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED: + // FIXME: if ! satisfied don't do this... return return_key_share (&gc->truth_uuid, connection); } diff --git a/src/backend/anastasis-httpd_truth_upload.c b/src/backend/anastasis-httpd_truth_upload.c index 0fb9017..0781f73 100644 --- a/src/backend/anastasis-httpd_truth_upload.c +++ b/src/backend/anastasis-httpd_truth_upload.c @@ -670,22 +670,17 @@ AH_handler_truth_post ( } /* check method is supported */ + if ( (0 != strcmp ("question", + type)) && + (NULL == + ANASTASIS_authorization_plugin_load (type, + AH_cfg)) ) { - struct TALER_Amount dummy; - - if ( (0 != strcmp ("question", - type)) && - (NULL == - ANASTASIS_authorization_plugin_load (type, - AH_cfg, - &dummy)) ) - { - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_ANASTASIS_TRUTH_UPLOAD_METHOD_NOT_SUPPORTED, - type); - } + GNUNET_JSON_parse_free (spec); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_BAD_REQUEST, + TALER_EC_ANASTASIS_TRUTH_UPLOAD_METHOD_NOT_SUPPORTED, + type); } if (storage_years > ANASTASIS_MAX_YEARS_STORAGE) -- cgit v1.2.3