commit bb7baf2cf70ae5238f90e04932e7fa4300258d87
parent 912ef81b38ce9793a318b3c5e245d1a98e172f67
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sat, 22 Nov 2025 08:44:04 +0100
add /terms and /privacy endpoints
Diffstat:
6 files changed, 162 insertions(+), 4 deletions(-)
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
@@ -82,6 +82,8 @@ taler_merchant_httpd_SOURCES = \
taler-merchant-httpd_helper.h \
taler-merchant-httpd_mhd.c \
taler-merchant-httpd_mhd.h \
+ taler-merchant-httpd_terms.c \
+ taler-merchant-httpd_terms.h \
taler-merchant-httpd_mfa.c \
taler-merchant-httpd_mfa.h \
taler-merchant-httpd_private-delete-account-ID.c \
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
@@ -106,6 +106,7 @@
#include "taler-merchant-httpd_post-orders-ID-refund.h"
#include "taler-merchant-httpd_spa.h"
#include "taler-merchant-httpd_statics.h"
+#include "taler-merchant-httpd_terms.h"
#ifdef HAVE_DONAU_DONAU_SERVICE_H
#include "taler-merchant-httpd_private-get-donau-instances.h"
@@ -1947,11 +1948,22 @@ url_handler (void *cls,
.handler = &TMH_MHD_handler_agpl_redirect
},
{
- .url_prefix = "/config",
+ .url_prefix = "/agpl",
.method = MHD_HTTP_METHOD_GET,
.skip_instance = true,
- .default_only = true,
- .handler = &MH_handler_config
+ .handler = &TMH_MHD_handler_agpl_redirect
+ },
+ {
+ .url_prefix = "/terms",
+ .method = MHD_HTTP_METHOD_GET,
+ .skip_instance = true,
+ .handler = &TMH_handler_terms
+ },
+ {
+ .url_prefix = "/privacy",
+ .method = MHD_HTTP_METHOD_GET,
+ .skip_instance = true,
+ .handler = &TMH_handler_privacy
},
/* Also serve the same /config per instance */
{
@@ -3053,6 +3065,7 @@ run (void *cls,
}
}
+ TMH_load_terms (cfg);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
diff --git a/src/backend/taler-merchant-httpd_terms.c b/src/backend/taler-merchant-httpd_terms.c
@@ -0,0 +1,79 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2019, 2021, 2025 Taler Systems SA
+
+ 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.
+
+ 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-merchant-httpd_terms.c
+ * @brief Handle /terms requests to return the terms of service
+ * @author Christian Grothoff
+ */
+#include "taler-merchant-httpd_terms.h"
+
+/**
+ * Our terms of service.
+ */
+static struct TALER_MHD_Legal *tos;
+
+
+/**
+ * Our privacy policy.
+ */
+static struct TALER_MHD_Legal *pp;
+
+
+MHD_RESULT
+TMH_handler_terms (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *rc)
+{
+ (void) rh;
+ (void) rc;
+ return TALER_MHD_reply_legal (connection,
+ tos);
+}
+
+
+MHD_RESULT
+TMH_handler_privacy (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *rc)
+{
+ (void) rh;
+ (void) rc;
+ return TALER_MHD_reply_legal (connection,
+ pp);
+}
+
+
+void
+TMH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ tos = TALER_MHD_legal_load (cfg,
+ "merchant",
+ "TERMS_DIR",
+ "TERMS_ETAG");
+ if (NULL == tos)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Terms of service not configured\n");
+ pp = TALER_MHD_legal_load (cfg,
+ "merchant",
+ "PRIVACY_DIR",
+ "PRIVACY_ETAG");
+ if (NULL == pp)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Privacy policy not configured\n");
+}
+
+
+/* end of taler-merchant-httpd_terms.c */
diff --git a/src/backend/taler-merchant-httpd_terms.h b/src/backend/taler-merchant-httpd_terms.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of TALER
+ Copyright (C) 2019, 2021, 2025 Taler Systems SA
+
+ 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.
+
+ 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file taler-merchant-httpd_terms.h
+ * @brief Handle /terms requests to return the terms of service
+ * @author Christian Grothoff
+ */
+#ifndef TALER_MERCHANT_HTTPD_TERMS_H
+#define TALER_MERCHANT_HTTPD_TERMS_H
+
+#include "taler-merchant-httpd.h"
+
+/**
+ * Handle a "/terms" request.
+ *
+ * @param rh this struct
+ * @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_handler_terms (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *rc);
+
+
+/**
+ * Handle a "/privacy" request.
+ *
+ * @param rc request context
+ * @param args array of additional options (must be empty for this function)
+ * @return MHD result code
+ */
+MHD_RESULT
+TMH_handler_privacy (const struct TMH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ struct TMH_HandlerContext *rc);
+
+
+/**
+ * Load our terms of service as per configuration.
+ *
+ * @param cfg configuration to process
+ */
+void
+TMH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
+#endif
diff --git a/src/backenddb/pg_increase_refund.c b/src/backenddb/pg_increase_refund.c
@@ -633,6 +633,7 @@ TMH_PG_increase_refund (
.reason = reason
};
+ // FIXME: return 'refund_serial' from this INSERT statement for #10577
PREPARE (pg,
"insert_refund",
"INSERT INTO merchant_refunds"
diff --git a/src/merchant-tools/taler-merchant-passwd.c b/src/merchant-tools/taler-merchant-passwd.c
@@ -59,7 +59,8 @@ run (void *cls,
if (NULL != args[1])
{
fprintf (stderr,
- "Superfluous command-line option `%s' specified\n");
+ "Superfluous command-line option `%s' specified\n",
+ args[1]);
global_ret = -1;
return;
}