summaryrefslogtreecommitdiff
path: root/src/exchange
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-01-27 16:09:25 +0100
committerChristian Grothoff <christian@grothoff.org>2023-01-27 16:09:25 +0100
commit59716ffdc48ad71a0f047f7e68f04b64d449d408 (patch)
tree8f913d7c24140df6ea6c2b46e389ffdf4363f618 /src/exchange
parentd79c23aaabb5dc1c9073555d574bea01b75668cd (diff)
downloadexchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.tar.gz
exchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.tar.bz2
exchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.zip
add logic to store attributes
Diffstat (limited to 'src/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-proof.c9
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-webhook.c40
2 files changed, 41 insertions, 8 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-proof.c b/src/exchange/taler-exchange-httpd_kyc-proof.c
index 11d179667..6d06f0c82 100644
--- a/src/exchange/taler-exchange-httpd_kyc-proof.c
+++ b/src/exchange/taler-exchange-httpd_kyc-proof.c
@@ -24,6 +24,7 @@
#include <jansson.h>
#include <microhttpd.h>
#include <pthread.h>
+#include "taler_attributes.h"
#include "taler_json_lib.h"
#include "taler_kyclogic_lib.h"
#include "taler_mhd_lib.h"
@@ -200,12 +201,10 @@ proof_cb (
const char *birthdate;
struct GNUNET_ShortHashCode kyc_prox;
- // FIXME: compute kyc_prox properly!
- memset (&kyc_prox,
- 0,
- sizeof (kyc_prox));
+ TALER_CRYPTO_attributes_to_kyc_prox (attributes,
+ &kyc_prox);
birthdate = json_string_value (json_object_get (attributes,
- "birthdate"));
+ TALER_ATTRIBUTE_BIRTHDATE));
TALER_CRYPTO_kyc_attributes_encrypt (&TEH_attribute_key,
attributes,
&ea,
diff --git a/src/exchange/taler-exchange-httpd_kyc-webhook.c b/src/exchange/taler-exchange-httpd_kyc-webhook.c
index 73038c139..e3acc1b46 100644
--- a/src/exchange/taler-exchange-httpd_kyc-webhook.c
+++ b/src/exchange/taler-exchange-httpd_kyc-webhook.c
@@ -24,6 +24,7 @@
#include <jansson.h>
#include <microhttpd.h>
#include <pthread.h>
+#include "taler_attributes.h"
#include "taler_json_lib.h"
#include "taler_mhd_lib.h"
#include "taler_kyclogic_lib.h"
@@ -140,8 +141,7 @@ TEH_kyc_webhook_cleanup (void)
/**
- * Function called with the result of a webhook
- * operation.
+ * Function called with the result of a KYC webhook operation.
*
* Note that the "decref" for the @a response
* will be done by the plugin.
@@ -154,6 +154,7 @@ TEH_kyc_webhook_cleanup (void)
* @param provider_legitimization_id set to legitimization process ID at the provider, or NULL if not supported or unknown
* @param status KYC status
* @param expiration until when is the KYC check valid
+ * @param attributes user attributes returned by the provider
* @param http_status HTTP status code of @a response
* @param[in] response to return to the HTTP client
*/
@@ -167,6 +168,7 @@ webhook_finished_cb (
const char *provider_legitimization_id,
enum TALER_KYCLOGIC_KycStatus status,
struct GNUNET_TIME_Absolute expiration,
+ const json_t *attributes,
unsigned int http_status,
struct MHD_Response *response)
{
@@ -179,7 +181,39 @@ webhook_finished_cb (
/* _successfully_ resumed case */
{
enum GNUNET_DB_QueryStatus qs;
-
+ size_t eas;
+ void *ea;
+ const char *birthdate;
+ struct GNUNET_ShortHashCode kyc_prox;
+
+ TALER_CRYPTO_attributes_to_kyc_prox (attributes,
+ &kyc_prox);
+ birthdate = json_string_value (json_object_get (attributes,
+ TALER_ATTRIBUTE_BIRTHDATE));
+ TALER_CRYPTO_kyc_attributes_encrypt (&TEH_attribute_key,
+ attributes,
+ &ea,
+ &eas);
+ qs = TEH_plugin->insert_kyc_attributes (
+ TEH_plugin->cls,
+ account_id,
+ &kyc_prox,
+ provider_section,
+ birthdate,
+ GNUNET_TIME_timestamp_get (),
+ GNUNET_TIME_absolute_to_timestamp (expiration),
+ eas,
+ ea);
+ GNUNET_free (ea);
+ if (qs < 0)
+ {
+ GNUNET_break (0);
+ kwh->response = TALER_MHD_make_error (TALER_EC_GENERIC_DB_STORE_FAILED,
+ "insert_kyc_attributes");
+ kwh->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ kwh_resume (kwh);
+ return;
+ }
qs = TEH_plugin->update_kyc_process_by_row (TEH_plugin->cls,
process_row,
provider_section,