summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-02-01 23:20:18 +0100
committerChristian Grothoff <christian@grothoff.org>2024-02-01 23:20:18 +0100
commita867291ea863948c604ebeeb1f6ffd3e684bb75b (patch)
tree37bffa0d6ab7d7d358deae6d25a4eb1c7a848ee5
parentc3fece4a3b521dc9694ca09b89fd20370f57b8bf (diff)
downloadmerchant-a867291ea863948c604ebeeb1f6ffd3e684bb75b.tar.gz
merchant-a867291ea863948c604ebeeb1f6ffd3e684bb75b.tar.bz2
merchant-a867291ea863948c604ebeeb1f6ffd3e684bb75b.zip
add TOTP key and method validation, allow strings to be specified in the TOTP method, bump protocol to v7
-rw-r--r--configure.ac13
-rw-r--r--src/backend/taler-merchant-httpd_config.c2
-rw-r--r--src/backend/taler-merchant-httpd_private-patch-otp-devices-ID.c9
-rw-r--r--src/backend/taler-merchant-httpd_private-post-otp-devices.c8
4 files changed, 20 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index 2c0cb654..a0dc66bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,7 @@ AS_CASE([$with_exchange],
[no], [AC_MSG_ERROR([--with-exchange is required])],
[LDFLAGS="-L$with_exchange/lib $LDFLAGS"
CPPFLAGS="-I$with_exchange/include $CPPFLAGS $POSTGRESQL_CPPFLAGS"])
+
AC_CHECK_HEADERS([taler/taler_util.h],
[AC_CHECK_LIB([talerutil], [TALER_denom_ewv_copy], libtalerutil=1)])
AM_CONDITIONAL(HAVE_TALERUTIL, test x$libtalerutil = x1)
@@ -252,6 +253,18 @@ AS_IF([test $libtalerutil != 1],
*** https://taler.net
*** ]])])
+libtalerjson=0
+AC_CHECK_HEADERS([taler/taler_json_lib.h],
+ [AC_CHECK_LIB([talerjson], [TALER_JSON_spec_otp_type], libtalerjson=1)])
+AM_CONDITIONAL(HAVE_TALERJSON, test x$libtalerjson = x1)
+AS_IF([test $libtalerjson != 1],
+ [AC_MSG_ERROR([[
+***
+*** You need libtalerjson >= 0.9.4 to build this program.
+*** This library is part of the GNU Taler exchange, available at
+*** https://taler.net
+*** ]])])
+
# Check for Taler's libtalerpq
diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c
index 87278116..b4906787 100644
--- a/src/backend/taler-merchant-httpd_config.c
+++ b/src/backend/taler-merchant-httpd_config.c
@@ -42,7 +42,7 @@
* #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in
* merchant_api_config.c!
*/
-#define MERCHANT_PROTOCOL_VERSION "6:1:2"
+#define MERCHANT_PROTOCOL_VERSION "7:0:3"
/**
diff --git a/src/backend/taler-merchant-httpd_private-patch-otp-devices-ID.c b/src/backend/taler-merchant-httpd_private-patch-otp-devices-ID.c
index aff85d8f..cb784b8d 100644
--- a/src/backend/taler-merchant-httpd_private-patch-otp-devices-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-otp-devices-ID.c
@@ -37,17 +37,16 @@ TMH_private_patch_otp_devices_ID (const struct TMH_RequestHandler *rh,
const char *device_id = hc->infix;
struct TALER_MERCHANTDB_OtpDeviceDetails tp = {0};
enum GNUNET_DB_QueryStatus qs;
- uint32_t otp_algorithm;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("otp_device_description",
(const char **) &tp.otp_description),
- GNUNET_JSON_spec_uint32 ("otp_algorithm",
- &otp_algorithm),
+ TALER_JSON_spec_otp_type ("otp_algorithm",
+ &tp.otp_algorithm),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint64 ("otp_ctr",
&tp.otp_ctr),
NULL),
- GNUNET_JSON_spec_string ("otp_key",
+ TALER_JSON_spec_otp_key ("otp_key",
(const char **) &tp.otp_key),
GNUNET_JSON_spec_end ()
};
@@ -66,8 +65,6 @@ TMH_private_patch_otp_devices_ID (const struct TMH_RequestHandler *rh,
: MHD_NO;
}
- tp.otp_algorithm = (enum TALER_MerchantConfirmationAlgorithm) otp_algorithm;
-
qs = TMH_db->update_otp (TMH_db->cls,
mi->settings.id,
device_id,
diff --git a/src/backend/taler-merchant-httpd_private-post-otp-devices.c b/src/backend/taler-merchant-httpd_private-post-otp-devices.c
index 5521ce97..ff70fb58 100644
--- a/src/backend/taler-merchant-httpd_private-post-otp-devices.c
+++ b/src/backend/taler-merchant-httpd_private-post-otp-devices.c
@@ -63,19 +63,18 @@ TMH_private_post_otp_devices (const struct TMH_RequestHandler *rh,
struct TALER_MERCHANTDB_OtpDeviceDetails tp = { 0 };
const char *device_id;
enum GNUNET_DB_QueryStatus qs;
- uint32_t otp_algorithm;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("otp_device_id",
&device_id),
GNUNET_JSON_spec_string ("otp_device_description",
(const char **) &tp.otp_description),
- GNUNET_JSON_spec_uint32 ("otp_algorithm",
- &otp_algorithm),
+ TALER_JSON_spec_otp_type ("otp_algorithm",
+ &tp.otp_algorithm),
GNUNET_JSON_spec_mark_optional (
GNUNET_JSON_spec_uint64 ("otp_ctr",
&tp.otp_ctr),
NULL),
- GNUNET_JSON_spec_string ("otp_key",
+ TALER_JSON_spec_otp_key ("otp_key",
(const char **) &tp.otp_key),
GNUNET_JSON_spec_end ()
};
@@ -95,7 +94,6 @@ TMH_private_post_otp_devices (const struct TMH_RequestHandler *rh,
: MHD_NO;
}
}
- tp.otp_algorithm = (enum TALER_MerchantConfirmationAlgorithm) otp_algorithm;
/* finally, interact with DB until no serialization error */
for (unsigned int i = 0; i<MAX_RETRIES; i++)