summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/taler-merchant-httpd.h')
-rw-r--r--src/backend/taler-merchant-httpd.h120
1 files changed, 118 insertions, 2 deletions
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h
index e8911b32..1e5e955d 100644
--- a/src/backend/taler-merchant-httpd.h
+++ b/src/backend/taler-merchant-httpd.h
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2021 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -25,6 +25,7 @@
#include "taler_merchantdb_lib.h"
#include <taler/taler_mhd_lib.h>
#include <gnunet/gnunet_mhd_compat.h>
+#include "taler_merchant_bank_lib.h"
/**
* Shorthand for exit jumps.
@@ -71,6 +72,17 @@ struct TMH_WireMethod
struct TALER_MerchantWireHashP h_wire;
/**
+ * Base URL of the credit facade.
+ */
+ char *credit_facade_url;
+
+ /**
+ * Authentication data to access the credit facade.
+ * May be uninitialized if not provided by the client.
+ */
+ json_t *credit_facade_credentials;
+
+ /**
* Is this wire method active (should it be included in new contracts)?
*/
bool active;
@@ -268,6 +280,33 @@ struct TMH_OrderRefundEventP
/**
+ * Event generated when a client picks up a reward.
+ */
+struct TMH_RewardPickupEventP
+{
+ /**
+ * Type is #TALER_DBEVENT_MERCHANT_REWARD_PICKUP.
+ */
+ struct GNUNET_DB_EventHeaderP header;
+
+ /**
+ * Always zero (for alignment).
+ */
+ uint32_t reserved GNUNET_PACKED;
+
+ /**
+ * Reward ID.
+ */
+ struct TALER_RewardIdentifierP reward_id;
+
+ /**
+ * Hash of the instance ID.
+ */
+ struct GNUNET_HashCode h_instance;
+
+};
+
+/**
* Possible flags indicating the state of an order.
*/
enum TMH_OrderStateFlags
@@ -369,6 +408,34 @@ struct TMH_HandlerContext;
/**
+ * Possible authorization scopes. This is a bit mask.
+ */
+enum TMH_AuthScope
+{
+ /**
+ * Nothing is authorized.
+ */
+ TMH_AS_NONE = 0,
+
+ /**
+ * Read-only access is OK. Any GET request is
+ * automatically OK.
+ */
+ TMH_AS_READ_ONLY = 1,
+
+ /**
+ * /login access to renew the token is OK.
+ */
+ TMH_AS_REFRESHABLE = 2,
+
+ /**
+ * Full access is granted to everything.
+ */
+ TMH_AS_ALL = 7
+};
+
+
+/**
* @brief Struct describing an URL and the handler for it.
*
* The overall URL is always @e url_prefix, optionally followed by the
@@ -389,8 +456,15 @@ struct TMH_RequestHandler
const char *url_prefix;
/**
+ * Required authentication scope for this request. NONE implies that
+ * #TMH_AS_ALL is required unless this is a #MHD_HTTP_METHOD_GET method, in which
+ * case #TMH_AS_READ_ONLY is sufficient.
+ */
+ enum TMH_AuthScope auth_scope;
+
+ /**
* Does this request include an identifier segment
- * (product_id, reserve_pub, order_id, tip_id, template_id, webhook_id) in the
+ * (product_id, reserve_pub, order_id, reward_id, template_id, webhook_id) in the
* second segment?
*/
bool have_id_segment;
@@ -515,6 +589,11 @@ struct TMH_HandlerContext
const char *url;
/**
+ * Copy of our original full URL with query parameters.
+ */
+ char *full_url;
+
+ /**
* Client-provided authentication token for this
* request, can be NULL.
*
@@ -545,6 +624,12 @@ struct TMH_HandlerContext
uint64_t total_upload;
/**
+ * Actual authentication scope of this request.
+ * Only set for ``/private/`` requests.
+ */
+ enum TMH_AuthScope auth_scope;
+
+ /**
* Set to true if this is an #MHD_HTTP_METHOD_POST or #MHD_HTTP_METHOD_PATCH request.
* (In principle #MHD_HTTP_METHOD_PUT may also belong, but we do not have PUTs
* in the API today, so we do not test for PUT.)
@@ -593,11 +678,33 @@ struct TMH_SuspendedConnection
extern char *TMH_currency;
/**
+ * What is the base URL for this merchant backend? NULL if it is not
+ * configured and is to be determined from HTTP headers (X-Forwarded-Host and
+ * X-Forwarded-Port and X-Forwarded-Prefix) of the reverse proxy.
+ */
+extern char *TMH_base_url;
+
+/**
+ * Length of the TMH_cspecs array.
+ */
+extern unsigned int TMH_num_cspecs;
+
+/**
+ * Rendering specs for currencies.
+ */
+extern struct TALER_CurrencySpecification *TMH_cspecs;
+
+/**
* Inform the auditor for all deposit confirmations (global option)
*/
extern int TMH_force_audit;
/**
+ * Context for all CURL operations (useful to the event loop)
+ */
+extern struct GNUNET_CURL_Context *TMH_curl_ctx;
+
+/**
* Handle to the database backend.
*/
extern struct TALER_MERCHANTDB_Plugin *TMH_db;
@@ -657,6 +764,15 @@ TMH_instance_decref (struct TMH_MerchantInstance *mi);
/**
+ * Free memory allocated by @a wm.
+ *
+ * @param[in] wm wire method to free
+ */
+void
+TMH_wire_method_free (struct TMH_WireMethod *wm);
+
+
+/**
* Lookup a merchant instance by its instance ID.
*
* @param instance_id identifier of the instance to resolve