[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: -remove truth expiration from /
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: -remove truth expiration from /config |
Date: |
Sun, 11 Jul 2021 15:38:40 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 56133c0 -remove truth expiration from /config
56133c0 is described below
commit 56133c09dadae767196bed9fdd9648000e47fd0c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Jul 11 15:38:37 2021 +0200
-remove truth expiration from /config
---
src/backend/anastasis-httpd.c | 17 ---
src/backend/anastasis-httpd.h | 12 +-
src/backend/anastasis-httpd_config.c | 5 +-
src/backend/anastasis-httpd_policy_upload.c | 121 ++++++++++++---------
src/backend/anastasis-httpd_truth_upload.c | 19 ++--
src/backend/anastasis.conf | 3 -
...astasis_reducer_backup_enter_user_attributes.sh | 1 +
src/cli/test_anastasis_reducer_enter_secret.sh | 1 -
src/include/anastasis_service.h | 47 --------
src/reducer/anastasis_api_redux.c | 15 +--
src/restclient/anastasis_api_config.c | 10 +-
11 files changed, 103 insertions(+), 148 deletions(-)
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 54583fa..23a9954 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -86,11 +86,6 @@ char *AH_fulfillment_url;
*/
char *AH_business_name;
-/**
- * Standard time range the truth expires.
- */
-struct GNUNET_TIME_Relative AH_truth_expiration;
-
/**
* Our server salt.
*/
@@ -786,18 +781,6 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (config,
- "anastasis",
- "TRUTH_EXPIRATION",
- &AH_truth_expiration))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- "anastasis",
- "TRUTH_EXPIRATION");
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
{
char *server_salt;
diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h
index 85406ab..6fe0023 100644
--- a/src/backend/anastasis-httpd.h
+++ b/src/backend/anastasis-httpd.h
@@ -28,6 +28,13 @@
#include <gnunet/gnunet_mhd_compat.h>
+/**
+ * For how many years do we allow users to store truth at most? Also
+ * how long we store things if the cost is zero.
+ */
+#define ANASTASIS_MAX_YEARS_STORAGE 5
+
+
/**
* @brief Struct describing an URL and the handler for it.
*/
@@ -187,11 +194,6 @@ extern char *AH_fulfillment_url;
*/
extern char *AH_business_name;
-/**
- * Standard time range the truth expires.
- */
-extern struct GNUNET_TIME_Relative AH_truth_expiration;
-
/**
* Our server salt.
*/
diff --git a/src/backend/anastasis-httpd_config.c
b/src/backend/anastasis-httpd_config.c
index fe5847c..fff6bcb 100644
--- a/src/backend/anastasis-httpd_config.c
+++ b/src/backend/anastasis-httpd_config.c
@@ -102,7 +102,7 @@ AH_handler_config (struct AH_RequestHandler *rh,
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
"{s:s, s:s, s:s, s:s, s:o, s:I,"
- " s:o, s:o, s:o, s:o, s:o}",
+ " s:o, s:o, s:o, s:o }",
"name",
"anastasis",
"version",
@@ -121,9 +121,6 @@ AH_handler_config (struct AH_RequestHandler *rh,
"truth_upload_fee",
TALER_JSON_from_amount (
&AH_truth_upload_fee),
- "truth_lifetime",
- GNUNET_JSON_from_time_rel (
- AH_truth_expiration),
"liability_limit",
TALER_JSON_from_amount (&AH_insurance),
"server_salt",
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index 500ad32..1c09a3c 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -148,6 +148,12 @@ struct PolicyUploadContext
*/
unsigned int response_code;
+ /**
+ * For how many years does the client still have
+ * to pay?
+ */
+ unsigned int years_to_pay;
+
/**
* true if client provided a payment secret / order ID?
*/
@@ -533,24 +539,12 @@ begin_payment (struct PolicyUploadContext *puc)
AH_backend_url);
{
char *order_id;
- struct GNUNET_TIME_Absolute now;
- struct GNUNET_TIME_Relative rem;
- unsigned int years_to_pay;
struct TALER_Amount upload_fee;
- now = GNUNET_TIME_absolute_get ();
- if (puc->paid_until.abs_value_us < now.abs_value_us)
- puc->paid_until = now;
- rem = GNUNET_TIME_absolute_get_difference (puc->paid_until,
- puc->end_date);
- years_to_pay = rem.rel_value_us
- / GNUNET_TIME_UNIT_YEARS.rel_value_us;
- if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
- years_to_pay++;
if (0 >
TALER_amount_multiply (&upload_fee,
&AH_annual_fee,
- years_to_pay))
+ puc->years_to_pay))
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (puc->con,
@@ -567,7 +561,7 @@ begin_payment (struct PolicyUploadContext *puc)
"summary", "Anastasis policy storage fee",
"products",
"description", "policy storage fee",
- "quantity", (json_int_t) years_to_pay,
+ "quantity", (json_int_t) puc->years_to_pay,
"unit", "years",
"order_id", order_id);
GNUNET_free (order_id);
@@ -802,11 +796,52 @@ AH_handler_policy_post (
}
}
+ /* check if the client insists on paying */
+ {
+ const char *req;
+ unsigned int years;
+
+ req = MHD_lookup_connection_value (connection,
+ MHD_GET_ARGUMENT_KIND,
+ "storage_duration");
+ if (NULL != req)
+ {
+ char dummy;
+
+ if (1 != sscanf (req,
+ "%u%c",
+ &years,
+ &dummy))
+ {
+ GNUNET_break_op (0);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_BAD_REQUEST,
+
TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "storage_duration (must be
non-negative number)");
+ }
+ }
+ else
+ {
+ years = 0;
+ }
+ puc->end_date = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
+ years));
+ }
+
/* get ready to hash (done here as we may go async for payments next) */
puc->hash_ctx = GNUNET_CRYPTO_hash_context_start ();
/* Check database to see if the transaction is permissible */
{
+ struct GNUNET_TIME_Relative rem;
+
+ rem = GNUNET_TIME_absolute_get_remaining (puc->end_date);
+ puc->years_to_pay = rem.rel_value_us
+ / GNUNET_TIME_UNIT_YEARS.rel_value_us;
+ if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
+ puc->years_to_pay++;
+
if (puc->payment_identifier_provided)
{
/* check if payment identifier is valid (existing and paid) */
@@ -824,10 +859,15 @@ AH_handler_policy_post (
TALER_EC_GENERIC_DB_FETCH_FAILED,
NULL);
- if ( (! paid) || (! valid_counter) )
+ if ( (! paid) ||
+ (! valid_counter) )
{
if (! valid_counter)
+ {
puc->payment_identifier_provided = false;
+ if (0 == puc->years_to_pay)
+ puc->years_to_pay = 1;
+ }
return prepare_payment (puc);
}
}
@@ -862,7 +902,9 @@ AH_handler_policy_post (
qs = db->increment_lifetime (db->cls,
account_pub,
&puc->payment_identifier,
- GNUNET_TIME_UNIT_YEARS);
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_YEARS,
+ ANASTASIS_MAX_YEARS_STORAGE));
if (qs <= 0)
return TALER_MHD_reply_with_error (puc->con,
MHD_HTTP_INTERNAL_SERVER_ERROR,
@@ -871,52 +913,31 @@ AH_handler_policy_post (
}
}
- /* check if the client insists on paying */
- {
- const char *req;
- unsigned int years;
-
- req = MHD_lookup_connection_value (connection,
- MHD_GET_ARGUMENT_KIND,
- "storage_duration");
- if (NULL != req)
- {
- char dummy;
-
- if (1 != sscanf (req,
- "%u%c",
- &years,
- &dummy))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_BAD_REQUEST,
-
TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "storage_duration (must be
non-negative number)");
- }
- }
- else
- {
- years = 0;
- }
- puc->end_date = GNUNET_TIME_relative_to_absolute (
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
- years));
- }
-
/* Check if existing policy matches upload (and if, skip it) */
{
struct GNUNET_HashCode hc;
enum ANASTASIS_DB_AccountStatus as;
uint32_t version;
+ struct GNUNET_TIME_Absolute now;
+ struct GNUNET_TIME_Relative rem;
as = db->lookup_account (db->cls,
account_pub,
&puc->paid_until,
&hc,
&version);
+ now = GNUNET_TIME_absolute_get ();
+ if (puc->paid_until.abs_value_us < now.abs_value_us)
+ puc->paid_until = now;
+ rem = GNUNET_TIME_absolute_get_difference (puc->paid_until,
+ puc->end_date);
+ puc->years_to_pay = rem.rel_value_us
+ / GNUNET_TIME_UNIT_YEARS.rel_value_us;
+ if (0 != (rem.rel_value_us % GNUNET_TIME_UNIT_YEARS.rel_value_us))
+ puc->years_to_pay++;
+
if ( (ANASTASIS_DB_ACCOUNT_STATUS_VALID_HASH_RETURNED == as) &&
- (puc->paid_until.abs_value_us < puc->end_date.abs_value_us) )
+ (0 != puc->years_to_pay) )
{
/* user requested extension, force payment */
as = ANASTASIS_DB_ACCOUNT_STATUS_PAYMENT_REQUIRED;
diff --git a/src/backend/anastasis-httpd_truth_upload.c
b/src/backend/anastasis-httpd_truth_upload.c
index 654e021..a408dcd 100644
--- a/src/backend/anastasis-httpd_truth_upload.c
+++ b/src/backend/anastasis-httpd_truth_upload.c
@@ -31,10 +31,6 @@
#include <taler/taler_signatures.h>
#include "anastasis_authorization_lib.h"
-/**
- * For how many years do we allow users to store truth at most?
- */
-#define MAX_YEARS_STORAGE 5
/**
* Information we track per truth upload.
@@ -508,6 +504,7 @@ AH_handler_truth_post (
const char *type;
enum GNUNET_DB_QueryStatus qs;
uint32_t storage_years;
+ struct GNUNET_TIME_Absolute paid_until;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_fixed_auto ("keyshare_data",
&keyshare_data),
@@ -666,7 +663,7 @@ AH_handler_truth_post (
}
}
- if (storage_years > MAX_YEARS_STORAGE)
+ if (storage_years > ANASTASIS_MAX_YEARS_STORAGE)
{
GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection,
@@ -674,6 +671,8 @@ AH_handler_truth_post (
TALER_EC_GENERIC_PARAMETER_MALFORMED,
"storage_duration_years");
}
+ if (0 == storage_years)
+ storage_years = 1;
{
struct TALER_Amount zero_amount;
@@ -683,7 +682,6 @@ AH_handler_truth_post (
if (0 != TALER_amount_cmp (&AH_truth_upload_fee,
&zero_amount))
{
- struct GNUNET_TIME_Absolute paid_until;
struct GNUNET_TIME_Absolute desired_until;
enum GNUNET_DB_QueryStatus qs;
@@ -742,6 +740,13 @@ AH_handler_truth_post (
GNUNET_YES),
qs);
}
+ else
+ {
+ paid_until
+ = GNUNET_TIME_relative_to_absolute (
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
+ ANASTASIS_MAX_YEARS_STORAGE));
+ }
}
@@ -754,7 +759,7 @@ AH_handler_truth_post (
encrypted_truth,
encrypted_truth_size,
type,
- AH_truth_expiration);
+ GNUNET_TIME_absolute_get_remaining (paid_until));
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
diff --git a/src/backend/anastasis.conf b/src/backend/anastasis.conf
index a25fade..ddc1a65 100644
--- a/src/backend/anastasis.conf
+++ b/src/backend/anastasis.conf
@@ -70,9 +70,6 @@ FULFILLMENT_URL = taler://fulfillment-success
# Base URL of our payment backend
# PAYMENT_BACKEND_URL = http://localhost:9976/
-# Standard expiration time in microseconds range of truth (2 years)
-TRUTH_EXPIRATION = 63115200000000
-
# Server salt 16 Byte
# SERVER_SALT = gUfO1KGOKYIFlFQg
diff --git a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
index c68894d..433438e 100755
--- a/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
+++ b/src/cli/test_anastasis_reducer_backup_enter_user_attributes.sh
@@ -103,6 +103,7 @@ echo " OK"
# Test user attributes collection in a backup state
echo -n "Test user attributes collection in a backup state ..."
+
anastasis-reducer -L WARNING -a \
'{"identity_attributes": {
"full_name": "Max Musterman",
diff --git a/src/cli/test_anastasis_reducer_enter_secret.sh
b/src/cli/test_anastasis_reducer_enter_secret.sh
index ecbbb07..372a3c6 100755
--- a/src/cli/test_anastasis_reducer_enter_secret.sh
+++ b/src/cli/test_anastasis_reducer_enter_secret.sh
@@ -388,7 +388,6 @@ do
PAY_URI=`jq --argjson INDEX $INDEX -r -e
'.policy_payment_requests[$INDEX].payto' < $TFILE`
# run wallet CLI
export PAY_URI
- bash
echo -n "$INDEX"
taler-wallet-cli --wallet-db=$WALLET_DB handle-uri $PAY_URI -y
2>wallet.err >wallet.log
echo -n ","
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 1a61e54..4fc04fd 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -91,12 +91,6 @@ struct ANASTASIS_Config
*/
struct TALER_Amount truth_upload_fee;
- /**
- * How long does the server store truth once uploaded
- * (per @e truth_upload_fee).
- */
- struct GNUNET_TIME_Relative truth_lifetime;
-
/**
* Maximum legal liability for data loss covered by the
* provider.
@@ -700,45 +694,4 @@ ANASTASIS_truth_store_cancel (
struct ANASTASIS_TruthStoreOperation *tso);
-#if 0
-// FIXME: BAD API & MISSING IMPLEMENTATION:
-
-/**
- * Defines a Callback for a Escrow Provider Inspection, simply passes
- * back the configuration of the provider (price, supported methods
- * .... )
- *
- * @param cls closure for the callback
- * @param policy 0 terminated string which contains the terms of service
- * @param cost defines the pricing of the provider
- */
-typedef void
-(*ANASTASIS_EscrowProviderInformation)(void *cls,
- const char *policy,
- const struct TALER_Amount *cost);
-
-
-/**
- * Does an EscrowProviderInspection GET /terms
- * Receives an EscrowProviderInformation Callback
- *
- * @param base_url url of the provider to inspect
- * @param cb callback for the request
- * @param cb_cls callback closure
- */
-struct ANASTASIS_EscrowProviderInspection *
-ANASTASIS_escrow_provider_inspect (const char *base_url,
- ANASTASIS_EscrowProviderInformation cb,
- void *cb_cls);
-
-
-/**
- * Cancels an EscrowProviderInspection
- * @param epi reference to the request
- */
-void
-ANASTASIS_escrow_provider_inspect_cancel (
- struct ANASTASIS_EscrowProviderInspection *epi);
-#endif
-
#endif /* _ANASTASIS_SERVICE_H */
diff --git a/src/reducer/anastasis_api_redux.c
b/src/reducer/anastasis_api_redux.c
index 32e124f..eb7e362 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -181,12 +181,6 @@ struct ConfigRequest
*/
struct TALER_Amount truth_upload_fee;
- /**
- * How long does the server store truth once uploaded
- * (per @e truth_upload_fee).
- */
- struct GNUNET_TIME_Relative truth_lifetime;
-
/**
* Maximum legal liability for data loss covered by the
* provider.
@@ -505,8 +499,8 @@ notify_waiting (struct ConfigRequest *cr)
json_array_append_new (methods_list,
mj));
}
- prov = json_pack ("{s:o, s:o, s:o, s:o, s:o,"
- " s:s, s:s, s:I, s:o, s:I}",
+ prov = json_pack ("{s:o, s:o, s:o, s:o, s:s,"
+ " s:s, s:I, s:o, s:I}",
"methods",
methods_list,
"annual_fee",
@@ -515,11 +509,9 @@ notify_waiting (struct ConfigRequest *cr)
TALER_JSON_from_amount (&cr->truth_upload_fee),
"liability_limit",
TALER_JSON_from_amount (&cr->liability_limit),
- "truth_lifetime",
- GNUNET_JSON_from_time_rel (cr->truth_lifetime),
- /* 6 */
"currency",
cr->currency,
+ /* 6 */
"business_name",
cr->business_name,
"storage_limit_in_megabytes",
@@ -590,7 +582,6 @@ config_cb (void *cls,
cr->storage_limit_in_megabytes = acfg->storage_limit_in_megabytes;
cr->annual_fee = acfg->annual_fee;
cr->truth_upload_fee = acfg->truth_upload_fee;
- cr->truth_lifetime = acfg->truth_lifetime;
cr->liability_limit = acfg->liability_limit;
cr->salt = acfg->salt;
}
diff --git a/src/restclient/anastasis_api_config.c
b/src/restclient/anastasis_api_config.c
index b0925fb..8e81a5a 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -118,8 +118,6 @@ handle_config_finished (void *cls,
&acfg.annual_fee),
TALER_JSON_spec_amount ("truth_upload_fee",
&acfg.truth_upload_fee),
- TALER_JSON_spec_relative_time ("truth_lifetime",
- &acfg.truth_lifetime),
TALER_JSON_spec_amount ("liability_limit",
&acfg.liability_limit),
GNUNET_JSON_spec_fixed_auto ("server_salt",
@@ -133,12 +131,14 @@ handle_config_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
+ response_code = 0;
break;
}
if (0 != strcmp (name,
"anastasis"))
{
GNUNET_JSON_parse_free (spec);
+ response_code = 0;
break;
}
{
@@ -155,6 +155,7 @@ handle_config_finished (void *cls,
&dummy))
{
GNUNET_break_op (0);
+ response_code = 0;
GNUNET_JSON_parse_free (spec);
break;
}
@@ -163,6 +164,7 @@ handle_config_finished (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Provider protocol version too new\n");
+ response_code = 0;
GNUNET_JSON_parse_free (spec);
break;
}
@@ -172,6 +174,7 @@ handle_config_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Provider protocol version too old\n");
GNUNET_break_op (0);
+ response_code = 0;
GNUNET_JSON_parse_free (spec);
break;
}
@@ -185,6 +188,7 @@ handle_config_finished (void *cls,
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
+ response_code = 0;
break;
}
@@ -192,6 +196,7 @@ handle_config_finished (void *cls,
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
+ response_code = 0;
break;
}
acfg.methods_length = json_array_size (methods);
@@ -221,6 +226,7 @@ handle_config_finished (void *cls,
{
GNUNET_break_op (0);
GNUNET_JSON_parse_free (spec);
+ response_code = 0;
goto end;
}
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: -remove truth expiration from /config,
gnunet <=