[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 04/08: reducer - worked on payment/upload
From: |
gnunet |
Subject: |
[taler-anastasis] 04/08: reducer - worked on payment/upload |
Date: |
Fri, 06 Nov 2020 18:06:29 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit df5de8f05c49e6e132a74fc7598cc7bb9ca70b9f
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Wed Nov 4 16:57:29 2020 +0100
reducer - worked on payment/upload
---
src/backend/anastasis-httpd_config.c | 8 ++-
src/include/anastasis_redux.h | 1 +
src/include/anastasis_service.h | 3 +-
src/lib/anastasis_api_backup_redux.c | 100 +++++++++++++++++++++++++++++++++++
src/lib/anastasis_api_config.c | 10 +++-
src/lib/anastasis_api_redux.c | 69 ++++++++++++++++++++++--
6 files changed, 183 insertions(+), 8 deletions(-)
diff --git a/src/backend/anastasis-httpd_config.c
b/src/backend/anastasis-httpd_config.c
index 70b1379..3517586 100644
--- a/src/backend/anastasis-httpd_config.c
+++ b/src/backend/anastasis-httpd_config.c
@@ -38,9 +38,13 @@ AH_handler_config (struct TMH_RequestHandler *rh,
{
json_t *methods = json_object ();
json_t *method_arr = json_array ();
+ struct ANASTASIS_CRYPTO_PowSalt salt;
if (! method_arr)
return MHD_HTTP_BAD_GATEWAY;
+ GNUNET_memcpy (&salt,
+ AH_server_salt,
+ strlen (AH_server_salt));
if (strstr (AH_supported_methods, "question"))
{
@@ -105,7 +109,7 @@ AH_handler_config (struct TMH_RequestHandler *rh,
json_object_set_new (methods, "methods", method_arr);
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:s, s:I, s:s, s:o, s:o, s:s}",
+ "{s:s, s:s, s:I, s:s, s:o, s:o, s:o, s:s}",
"name",
"anastasis",
"methods",
@@ -118,6 +122,8 @@ AH_handler_config (struct TMH_RequestHandler *rh,
TALER_JSON_from_amount (&AH_annual_fee),
"insurance",
TALER_JSON_from_amount (&AH_insurance),
+ "server_salt",
+ GNUNET_JSON_from_data_auto (&salt),
"version", "0:0:0");
}
diff --git a/src/include/anastasis_redux.h b/src/include/anastasis_redux.h
index 61d151c..de3985f 100644
--- a/src/include/anastasis_redux.h
+++ b/src/include/anastasis_redux.h
@@ -27,6 +27,7 @@
#include <gnunet/gnunet_util_lib.h>
#include "anastasis_error_codes.h"
#include "anastasis_service.h"
+#include "anastasis.h"
#include <regex.h>
#define ANASTASIS_GENERIC_STATES(REDUX_STATE) \
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index 2a13dd6..52bb12f 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -244,7 +244,8 @@ typedef void
const json_t *methods,
const char *conf_currency,
const struct TALER_Amount *annual_fee,
- const struct TALER_Amount *insurance);
+ const struct TALER_Amount *insurance,
+ const struct ANASTASIS_CRYPTO_PowSalt
*server_salt);
/**
diff --git a/src/lib/anastasis_api_backup_redux.c
b/src/lib/anastasis_api_backup_redux.c
index 72cf67a..31d1181 100644
--- a/src/lib/anastasis_api_backup_redux.c
+++ b/src/lib/anastasis_api_backup_redux.c
@@ -63,6 +63,69 @@ ANASTASIS_backup_state_to_string (enum ANASTASIS_BackupState
bs)
}
+/**
+ * State for a "truth upload" CMD.
+ */
+struct TruthUploadState
+{
+ /**
+ * URL of the anastasis backend.
+ */
+ const char *anastasis_url;
+
+ /**
+ * The ID data to generate user identifier
+ */
+ const json_t *id_data;
+
+ /**
+ * The escrow method
+ */
+ const char *method;
+
+ /**
+ * Instructions to be returned to client/user
+ * (e.g. "Look at your smartphone. SMS was sent to you")
+ */
+ const char *instructions;
+
+ /**
+ * Mime type of truth_data (eg. jpeg, string etc.)
+ */
+ const char *mime_type;
+
+ /**
+ * The truth_data (e.g. hash of answer to a secure question)
+ */
+ const void *truth_data;
+
+ /**
+ * Size of truth_data
+ */
+ size_t truth_data_size;
+
+ /**
+ * Expected status code.
+ */
+ unsigned int http_status;
+
+ /**
+ * The /truth POST operation handle.
+ */
+ struct ANASTASIS_TruthUpload *tuo;
+
+ /**
+ * closure for the payment callback
+ */
+ void *tpc_cls;
+
+ /**
+ * Truth object
+ */
+ struct ANASTASIS_Truth *truth;
+};
+
+
/**
* Callback function FIXME: Description.
*
@@ -853,6 +916,42 @@ enter_secret (json_t *state,
json_object_set_new (state,
"core_secret",
arguments));
+
+ // initialize #ANASTASIS_Policy array
+ json_t *authentication_json_array =
+ json_object_get (state,
+ "authentication_methods");
+
+ GNUNET_assert (json_is_array (authentication_json_array));
+ json_t *provider_json_array = json_object_get (state,
+ "authentication_providers");
+
+ GNUNET_assert (json_is_array (provider_json_array));
+ json_t *policy_json_array = json_object_get (state,
+ "policies");
+
+ GNUNET_assert (json_is_array (policy_json_array));
+ const struct ANASTASIS_Policy *policies[json_array_size (policy_json_array)];
+
+ for (unsigned int i = 0; i < json_array_size (policy_json_array); i++)
+ {
+ struct ANASTASIS_Truth *truths;
+ size_t index;
+ json_t *method;
+ json_t *policy_json = json_array_get (policy_json_array, i);
+
+ GNUNET_assert (NULL != policy_json);
+ json_t *methods = json_object_get (policy_json,
+ "methods");
+
+ GNUNET_assert (json_is_array (methods));
+ json_array_foreach (methods, index, method)
+ {
+
+ }
+ }
+ // try uploading recovery document
+ /*
set_state (state,
ANASTASIS_backup_state_to_string (
ANASTASIS_BACKUP_STATE_POLICIES_PAYING));
@@ -860,6 +959,7 @@ enter_secret (json_t *state,
cb (cb_cls,
ANASTASIS_EC_NONE,
state);
+ */
return NULL;
}
diff --git a/src/lib/anastasis_api_config.c b/src/lib/anastasis_api_config.c
index febe420..1f65ab3 100644
--- a/src/lib/anastasis_api_config.c
+++ b/src/lib/anastasis_api_config.c
@@ -78,6 +78,11 @@ struct ANASTASIS_ConfigOperation
* Currency of the cost;
*/
const char *currency;
+
+ /**
+ * Server salt.
+ */
+ struct ANASTASIS_CRYPTO_PowSalt salt;
};
@@ -112,6 +117,7 @@ handle_config_finished (void *cls,
GNUNET_JSON_spec_string ("currency", &co->currency),
TALER_JSON_spec_amount ("annual_fee", &co->cost),
TALER_JSON_spec_amount ("insurance", &co->insurance),
+ GNUNET_JSON_spec_fixed_auto ("server_salt", &co->salt),
GNUNET_JSON_spec_end ()
};
@@ -132,7 +138,8 @@ handle_config_finished (void *cls,
co->methods,
co->currency,
&co->cost,
- &co->insurance
+ &co->insurance,
+ &co->salt
);
GNUNET_JSON_parse_free (spec);
ANASTASIS_config_cancel (co);
@@ -165,6 +172,7 @@ handle_config_finished (void *cls,
NULL,
NULL,
NULL,
+ NULL,
NULL);
co->cb = NULL;
}
diff --git a/src/lib/anastasis_api_redux.c b/src/lib/anastasis_api_redux.c
index e21aa15..007420d 100644
--- a/src/lib/anastasis_api_redux.c
+++ b/src/lib/anastasis_api_redux.c
@@ -124,6 +124,11 @@ struct ConfigRequest
*/
struct TALER_Amount backend_cost;
+ /**
+ * salt of the provider server used for generation of user identifier.
+ */
+ struct ANASTASIS_CRYPTO_PowSalt backend_salt;
+
/**
* Supported methods.
*/
@@ -264,7 +269,11 @@ add_config_to_state (struct ConfigRequest *cr,
method_type,
ma_arr = json_array ()));
}
- prov = json_pack ("{s:o, s:o, s:o, s:s, s:s}",
+ char *provider_salt = GNUNET_STRINGS_data_to_string_alloc (
+ &cr->backend_salt,
+ sizeof (struct
+ ANASTASIS_CRYPTO_PowSalt));
+ prov = json_pack ("{s:o, s:o, s:o, s:s, s:s, s:s}",
"method_cost",
json_object_get (method,
"cost"),
@@ -275,7 +284,10 @@ add_config_to_state (struct ConfigRequest *cr,
"provider_url",
cr->backend_url,
"provider_name",
- cr->backend_name);
+ cr->backend_name,
+ "provider_salt",
+ provider_salt);
+ GNUNET_free (provider_salt);
GNUNET_assert (0 == json_object_set_new (ma,
cr->backend_id,
prov));
@@ -320,7 +332,6 @@ conclude_select_country (struct SelectCountryHandle *sch)
sch->cb (NULL,
ANASTASIS_EC_NONE,
sch->state);
- // free_select_country (sch);
}
@@ -349,6 +360,7 @@ config_request_timeout (void *cls)
* @param methods supported methods by this provider
* @param annual_fee Annual fee of this service
* @param insurance Amount of insurance of this service
+ * @param salt Salt of this provider server
*/
static void
config_cb (void *cls,
@@ -356,7 +368,8 @@ config_cb (void *cls,
const json_t *methods,
const char *conf_currency,
const struct TALER_Amount *annual_fee,
- const struct TALER_Amount *insurance)
+ const struct TALER_Amount *insurance,
+ const struct ANASTASIS_CRYPTO_PowSalt *salt)
{
struct ConfigRequest *cr = cls;
struct SelectCountryHandle *sch = cr->sch;
@@ -374,6 +387,7 @@ config_cb (void *cls,
cr->backend_cost = *annual_fee;
cr->backend_currency = GNUNET_strdup (conf_currency);
cr->backend_insurance = *insurance;
+ cr->backend_salt = *salt;
}
conclude_select_country (sch);
}
@@ -597,6 +611,19 @@ select_continent (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
+ if (NULL == arguments)
+ {
+ json_t *error = json_pack ("{s:I, s:s}",
+ "code",
+ (json_int_t) ANASTASIS_EC_INVALID,
+ "hint",
+ "Arguments missing!");
+ cb (cb_cls,
+ ANASTASIS_EC_INVALID,
+ error);
+ return NULL;
+ }
+
size_t index;
json_t *country;
json_t *redux_countries = ANASTASIS_redux_countries_init_ ();
@@ -664,6 +691,19 @@ select_country (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
+ if (NULL == arguments)
+ {
+ json_t *error = json_pack ("{s:I, s:s}",
+ "code",
+ (json_int_t) ANASTASIS_EC_INVALID,
+ "hint",
+ "Arguments missing!");
+ cb (cb_cls,
+ ANASTASIS_EC_INVALID,
+ error);
+ return NULL;
+ }
+
json_t *root;
json_t *provider_list;
char *dn;
@@ -754,6 +794,14 @@ select_country (json_t *state,
"provider_name"));
const char *provider_id = json_string_value (json_object_get (provider,
"provider_id"));
+ const char *provider_salt_str =
+ json_string_value (json_object_get (provider,
+ "provider_salt"));
+
+ GNUNET_STRINGS_string_to_data (provider_salt_str,
+ strlen (provider_salt_str),
+ &cr->backend_salt,
+ sizeof (cr->backend_salt));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Url is: %s\n", url);
cr->backend_url = GNUNET_strdup (url);
@@ -881,7 +929,18 @@ enter_user_attributes (json_t *state,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- GNUNET_assert (NULL != arguments);
+ if (NULL == arguments)
+ {
+ json_t *error = json_pack ("{s:I, s:s}",
+ "code",
+ (json_int_t) ANASTASIS_EC_INVALID,
+ "hint",
+ "Arguments missing!");
+ cb (cb_cls,
+ ANASTASIS_EC_INVALID,
+ error);
+ return NULL;
+ }
json_t *attributes = json_object_get (arguments,
"identity_attributes");
GNUNET_assert (NULL != attributes);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated (f7e2529 -> eb4a3aa), gnunet, 2020/11/06
- [taler-anastasis] 02/08: description, gnunet, 2020/11/06
- [taler-anastasis] 04/08: reducer - worked on payment/upload,
gnunet <=
- [taler-anastasis] 01/08: add insurance to config, gnunet, 2020/11/06
- [taler-anastasis] 06/08: work on truth upload, gnunet, 2020/11/06
- [taler-anastasis] 05/08: initialize truths, gnunet, 2020/11/06
- [taler-anastasis] 07/08: Merge branch 'master' of ssh://git.taler.net/anastasis, gnunet, 2020/11/06
- [taler-anastasis] 08/08: fix db, fix reducer, gnunet, 2020/11/06
- [taler-anastasis] 03/08: reducer - better error handling, gnunet, 2020/11/06