summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-09 16:18:44 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-09 16:18:44 +0200
commit91d76e7861149af36a8875bbb0811dda4e0485c4 (patch)
treec8566ab3c7b8ffcfbe215b823fbe273ec93f72ec /src/backend
parentd16c03c64da9f58e9bbf6b14bae69da633566da6 (diff)
downloadmerchant-91d76e7861149af36a8875bbb0811dda4e0485c4.tar.gz
merchant-91d76e7861149af36a8875bbb0811dda4e0485c4.tar.bz2
merchant-91d76e7861149af36a8875bbb0811dda4e0485c4.zip
-starting work on /kyc handler
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/Makefile.am2
-rw-r--r--src/backend/taler-merchant-httpd.c19
-rw-r--r--src/backend/taler-merchant-httpd_get-orders-ID.c4
-rw-r--r--src/backend/taler-merchant-httpd_helper.c4
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c84
-rw-r--r--src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.h59
6 files changed, 166 insertions, 6 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index da825d3b..073fff5e 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -48,6 +48,8 @@ taler_merchant_httpd_SOURCES = \
taler-merchant-httpd_private-get-instances.h \
taler-merchant-httpd_private-get-instances-ID.c \
taler-merchant-httpd_private-get-instances-ID.h \
+ taler-merchant-httpd_private-get-instances-ID-kyc.c \
+ taler-merchant-httpd_private-get-instances-ID-kyc.h \
taler-merchant-httpd_private-get-products.c \
taler-merchant-httpd_private-get-products.h \
taler-merchant-httpd_private-get-products-ID.c \
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index e031c2ba..feb90b28 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -39,6 +39,7 @@
#include "taler-merchant-httpd_private-delete-transfers-ID.h"
#include "taler-merchant-httpd_private-get-instances.h"
#include "taler-merchant-httpd_private-get-instances-ID.h"
+#include "taler-merchant-httpd_private-get-instances-ID-kyc.h"
#include "taler-merchant-httpd_private-get-products.h"
#include "taler-merchant-httpd_private-get-products-ID.h"
#include "taler-merchant-httpd_private-get-orders.h"
@@ -147,7 +148,7 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
char *TMH_default_auth;
-int
+enum GNUNET_GenericReturnValue
TMH_check_auth (const char *token,
const struct GNUNET_ShortHashCode *salt,
const struct GNUNET_HashCode *hash)
@@ -646,6 +647,16 @@ url_handler (void *cls,
/* Body should be pretty small. */
.max_upload = 1024 * 1024
},
+ /* POST /kyc: */
+ {
+ .url_prefix = "/instances/",
+ .url_suffix = "kyc",
+ .method = MHD_HTTP_METHOD_GET,
+ .skip_instance = true,
+ .default_only = true,
+ .have_id_segment = true,
+ .handler = &TMH_private_get_instances_default_ID_kyc,
+ },
{
NULL
}
@@ -685,6 +696,12 @@ url_handler (void *cls,
/* Body should be pretty small. */
.max_upload = 1024 * 1024,
},
+ /* GET /kyc: */
+ {
+ .url_prefix = "/kyc",
+ .method = MHD_HTTP_METHOD_GET,
+ .handler = &TMH_private_get_instances_ID_kyc,
+ },
/* GET /products: */
{
.url_prefix = "/products",
diff --git a/src/backend/taler-merchant-httpd_get-orders-ID.c b/src/backend/taler-merchant-httpd_get-orders-ID.c
index 0025a6ce..dbb5ef10 100644
--- a/src/backend/taler-merchant-httpd_get-orders-ID.c
+++ b/src/backend/taler-merchant-httpd_get-orders-ID.c
@@ -427,7 +427,7 @@ TMH_make_order_status_url (struct MHD_Connection *con,
"?token=");
GNUNET_buffer_write_data_encoded (&buf,
(char *) claim_token,
- sizeof (struct TALER_ClaimTokenP));
+ sizeof (*claim_token));
num_qp++;
}
@@ -454,7 +454,7 @@ TMH_make_order_status_url (struct MHD_Connection *con,
"?h_contract=");
GNUNET_buffer_write_data_encoded (&buf,
(char *) h_contract,
- sizeof (struct GNUNET_HashCode));
+ sizeof (*h_contract));
}
return GNUNET_buffer_reap_str (&buf);
diff --git a/src/backend/taler-merchant-httpd_helper.c b/src/backend/taler-merchant-httpd_helper.c
index 2427b1e0..f4129e0e 100644
--- a/src/backend/taler-merchant-httpd_helper.c
+++ b/src/backend/taler-merchant-httpd_helper.c
@@ -315,9 +315,7 @@ TMH_taxes_array_valid (const json_t *taxes)
struct TMH_WireMethod *
TMH_setup_wire_account (const char *payto_uri)
{
- // FIXME: avoid use of huge 512-bit salt!?
- // Seems 128-bit should suffice, right?
- struct GNUNET_HashCode salt;
+ struct TALER_WireSalt salt;
struct TMH_WireMethod *wm;
GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
new file mode 100644
index 00000000..a87b4162
--- /dev/null
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -0,0 +1,84 @@
+/*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems SA
+
+ GNU Taler is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation; either version 3,
+ or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not,
+ see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file taler-merchant-httpd_private-get-instances-ID-kyc.c
+ * @brief implementing GET /instances/$ID/kyc request handling
+ * @kycor Christian Grothoff
+ * @kycor Florian Dold
+ */
+#include "platform.h"
+#include "taler-merchant-httpd_private-get-instances-ID-kyc.h"
+#include "taler-merchant-httpd_helper.h"
+#include <taler/taler_json_lib.h>
+
+
+/**
+ * Check the KYC status of an instance.
+ *
+ * @param mi instance to check KYC status of
+ * @param connection the MHD connection to handle
+ * @param[in,out] hc context with further information about the request
+ * @return MHD result code
+ */
+static MHD_RESULT
+get_instances_ID_kyc (struct TMH_MerchantInstance *mi,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc)
+{
+ GNUNET_break (0);
+ return MHD_NO;
+}
+
+
+MHD_RESULT
+TMH_private_get_instances_ID_kyc (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc)
+{
+ struct TMH_MerchantInstance *mi = hc->instance;
+
+ return get_instances_ID_kyc (mi,
+ connection,
+ hc);
+}
+
+
+MHD_RESULT
+TMH_private_get_instances_default_ID_kyc (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc)
+{
+ struct TMH_MerchantInstance *mi;
+
+ mi = TMH_lookup_instance (hc->infix);
+ if (NULL == mi)
+ {
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN,
+ hc->infix);
+ }
+ return get_instances_ID_kyc (mi,
+ connection,
+ hc);
+}
+
+
+/* end of taler-merchant-httpd_private-get-instances-ID-kyc.c */
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.h b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.h
new file mode 100644
index 00000000..58762c86
--- /dev/null
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.h
@@ -0,0 +1,59 @@
+/*
+ This file is part of GNU Taler
+ (C) 2021 Taler Systems SA
+
+ GNU Taler is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation; either version 3,
+ or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with TALER; see the file COPYING. If not,
+ see <http://www.gnu.org/licenses/>
+*/
+
+/**
+ * @file taler-merchant-httpd_private-get-instances-ID-kyc.h
+ * @brief implements GET /instances/$ID/kyc request handling
+ * @author Christian Grothoff
+ */
+#ifndef TALER_MERCHANT_HTTPD_PRIVATE_GET_INSTANCES_ID_KYC_H
+#define TALER_MERCHANT_HTTPD_PRIVATE_GET_INSTANCES_ID_KYC_H
+#include "taler-merchant-httpd.h"
+
+
+/**
+ * Change the instance's kyc settings.
+ * This is the handler called using the instance's own kycentication.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] hc context with further information about the request
+ * @return MHD result code
+ */
+MHD_RESULT
+TMH_private_get_instances_ID_kyc (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc);
+
+
+/**
+ * Change the instance's kyc settings.
+ * This is the handler called using the default instance's kycentication.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] hc context with further information about the request
+ * @return MHD result code
+ */
+MHD_RESULT
+TMH_private_get_instances_default_ID_kyc (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *hc);
+
+#endif