commit e8ac60873f7861f7bedd4f6dfafe1be38f600ffa
parent e2aa3222a2f91da46866562334ecc0550b3cc253
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 15 Apr 2025 13:00:19 +0200
remove link, feature just does not work nicely
Diffstat:
9 files changed, 1 insertion(+), 340 deletions(-)
diff --git a/src/challenger/challenger-httpd.c b/src/challenger/challenger-httpd.c
@@ -247,11 +247,6 @@ url_handler (void *cls,
.handler = &CH_handler_challenge
},
{
- .url = "/challenge/",
- .method = MHD_HTTP_METHOD_GET,
- .handler = &CH_handler_challenge_get
- },
- {
.url = "/solve/",
.method = MHD_HTTP_METHOD_POST,
.handler = &CH_handler_solve
diff --git a/src/challenger/challenger-httpd_challenge.c b/src/challenger/challenger-httpd_challenge.c
@@ -361,20 +361,12 @@ send_tan (struct ChallengeContext *bc)
{
json_t *root;
int mret;
- char *my_url;
- GNUNET_asprintf (&my_url,
- "%schallenge/%s",
- CH_base_url,
- bc->hc->path);
root = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_string ("challenger_url",
- my_url),
GNUNET_JSON_pack_object_incref ("address",
bc->address),
GNUNET_JSON_pack_int64 ("pin",
bc->tan));
- GNUNET_free (my_url);
mret = TALER_TEMPLATING_fill2 (CH_message_template,
CH_message_template_len,
root,
@@ -834,160 +826,3 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
return res;
}
}
-
-
-MHD_RESULT
-CH_handler_challenge_get (struct CH_HandlerContext *hc,
- const char *upload_data,
- size_t *upload_data_size)
-{
- struct CHALLENGER_ValidationNonceP nonce;
- struct GNUNET_TIME_Absolute last_tx_time;
- json_t *address;
- uint32_t pin_attempts_left;
- char *client_redirect_uri;
-
- if (GNUNET_OK !=
- GNUNET_STRINGS_string_to_data (hc->path,
- strlen (hc->path),
- &nonce,
- sizeof (nonce)))
- {
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (
- hc->connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_GENERIC_PARAMETER_MISSING,
- hc->path);
- }
- for (unsigned int r = 0; r < MAX_RETRIES; r++)
- {
- enum GNUNET_DB_QueryStatus qs;
-
- qs = CH_db->challenge_get_address_and_stats (
- CH_db->cls,
- &nonce,
- &address,
- &last_tx_time,
- &pin_attempts_left,
- &client_redirect_uri);
- switch (qs)
- {
- case GNUNET_DB_STATUS_HARD_ERROR:
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (
- hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "challenge-get-address-and-stats");
- case GNUNET_DB_STATUS_SOFT_ERROR:
- if (r < MAX_RETRIES - 1)
- continue;
- GNUNET_break (0);
- return TALER_MHD_reply_with_error (
- hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_GENERIC_DB_STORE_FAILED,
- "challenge-get-address-and-stats");
- case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- GNUNET_break_op (0);
- return TALER_MHD_reply_with_error (
- hc->connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_CHALLENGER_GENERIC_VALIDATION_UNKNOWN,
- NULL);
- case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
- break;
- }
- break;
- }
- if (NULL == address)
- {
- /* Very wrong location, we never got an address, redirect user to entry point */
- char *url;
- struct MHD_Response *response;
- MHD_RESULT res;
-
- GNUNET_asprintf (&url,
- "%sauthorize/%s",
- CH_base_url,
- hc->path);
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == response)
- {
- GNUNET_break (0);
- GNUNET_free (url);
- return MHD_NO;
- }
- TALER_MHD_add_global_headers (response);
- if (MHD_NO ==
- MHD_add_response_header (response,
- MHD_HTTP_HEADER_LOCATION,
- url))
- {
- GNUNET_break (0);
- MHD_destroy_response (response);
- GNUNET_free (client_redirect_uri);
- GNUNET_free (url);
- return MHD_NO;
- }
- GNUNET_free (url);
- res = MHD_queue_response (hc->connection,
- MHD_HTTP_FOUND,
- response);
- MHD_destroy_response (response);
- GNUNET_free (client_redirect_uri);
- return res;
- }
- if (0 == pin_attempts_left)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Address changes exhausted PIN limit for this address\n");
- GNUNET_free (client_redirect_uri);
- json_decref (address);
- return TALER_MHD_reply_with_error (
- hc->connection,
- MHD_HTTP_TOO_MANY_REQUESTS,
- TALER_EC_CHALLENGER_TOO_MANY_ATTEMPTS,
- "client exceeded authorization attempts limit (too many PINs)");
- }
- {
- struct MHD_Response *resp;
- MHD_RESULT res;
- json_t *args;
- unsigned int http_status;
-
- args = GNUNET_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("attempts_left",
- pin_attempts_left),
- GNUNET_JSON_pack_string ("nonce",
- hc->path),
- GNUNET_JSON_pack_string ("type",
- "created"),
- GNUNET_JSON_pack_object_incref ("address",
- address),
- GNUNET_JSON_pack_bool ("transmitted",
- false),
- GNUNET_JSON_pack_timestamp ("retransmission_time",
- GNUNET_TIME_absolute_to_timestamp (
- GNUNET_TIME_absolute_add (
- last_tx_time,
- CH_validation_duration)))
- );
- http_status = MHD_HTTP_OK;
- resp = TALER_MHD_make_json (args);
- GNUNET_break (MHD_YES ==
- MHD_add_response_header (resp,
- MHD_HTTP_HEADER_CACHE_CONTROL,
- "no-store,no-cache"));
- res = MHD_queue_response (hc->connection,
- http_status,
- resp);
- MHD_destroy_response (resp);
- GNUNET_free (client_redirect_uri);
- json_decref (address);
- return res;
- }
-}
diff --git a/src/challenger/challenger-httpd_challenge.h b/src/challenger/challenger-httpd_challenge.h
@@ -45,18 +45,4 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
size_t *upload_data_size);
-/**
- * Handle a client GETting a /challenge request
- *
- * @param hc context of the connection
- * @param upload_data upload data, if any
- * @param[in,out] upload_data_size remaining data in @a upload_data, to be updated
- * @return MHD result code
- */
-MHD_RESULT
-CH_handler_challenge_get (struct CH_HandlerContext *hc,
- const char *upload_data,
- size_t *upload_data_size);
-
-
#endif
diff --git a/src/challenger/default-challenge-message.txt b/src/challenger/default-challenge-message.txt
@@ -1 +1 @@
-Please enter the PIN {{pin}} at {{challenger_url}} to verify your address.
+Please enter the PIN {{pin}} to verify your address.
diff --git a/src/challengerdb/Makefile.am b/src/challengerdb/Makefile.am
@@ -75,7 +75,6 @@ libchallenger_plugin_db_postgres_la_SOURCES = \
pg_client_modify.h pg_client_modify.c \
pg_client_delete.h pg_client_delete.c \
pg_client_check.h pg_client_check.c \
- pg_challenge_get_address_and_stats.h pg_challenge_get_address_and_stats.c \
pg_info_get_token.h pg_info_get_token.c \
pg_token_add_token.h pg_token_add_token.c \
pg_setup_nonce.h pg_setup_nonce.c \
diff --git a/src/challengerdb/pg_challenge_get_address_and_stats.c b/src/challengerdb/pg_challenge_get_address_and_stats.c
@@ -1,73 +0,0 @@
-/*
- This file is part of Challenger
- Copyright (C) 2023 Taler Systems SA
-
- Challenger 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
- Foundation; either version 3, or (at your option) any later version.
-
- Challenger 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
- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file challengerdb/pg_challenge_get_address_and_stats.c
- * @brief Implementation of the challenge_get_address_and_stats function for Postgres
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <taler/taler_error_codes.h>
-#include <taler/taler_dbevents.h>
-#include <taler/taler_pq_lib.h>
-#include "pg_challenge_get_address_and_stats.h"
-#include "pg_helper.h"
-
-enum GNUNET_DB_QueryStatus
-CH_PG_challenge_get_address_and_stats (
- void *cls,
- const struct CHALLENGER_ValidationNonceP *nonce,
- json_t **address,
- struct GNUNET_TIME_Absolute *last_tx_time,
- uint32_t *auth_attempts_left,
- char **client_redirect_uri)
-{
- struct PostgresClosure *pg = cls;
- struct GNUNET_PQ_QueryParam params[] = {
- GNUNET_PQ_query_param_auto_from_type (nonce),
- GNUNET_PQ_query_param_end
- };
- struct GNUNET_PQ_ResultSpec rs[] = {
- GNUNET_PQ_result_spec_allow_null (
- TALER_PQ_result_spec_json ("address",
- address),
- NULL),
- GNUNET_PQ_result_spec_absolute_time ("last_tx_time",
- last_tx_time),
- GNUNET_PQ_result_spec_uint32 ("auth_attempts_left",
- auth_attempts_left),
- GNUNET_PQ_result_spec_allow_null (
- GNUNET_PQ_result_spec_string ("client_redirect_uri",
- client_redirect_uri),
- NULL),
- GNUNET_PQ_result_spec_end
- };
-
- *address = NULL;
- *client_redirect_uri = NULL;
- PREPARE (pg,
- "challenge_get_address_and_stats",
- "SELECT"
- " address"
- " ,last_tx_time"
- " ,auth_attempts_left"
- " ,client_redirect_uri"
- " FROM validations"
- " WHERE nonce=$1;");
- return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
- "challenge_get_address_and_stats",
- params,
- rs);
-}
diff --git a/src/challengerdb/pg_challenge_get_address_and_stats.h b/src/challengerdb/pg_challenge_get_address_and_stats.h
@@ -1,53 +0,0 @@
-/*
- This file is part of Challenger
- Copyright (C) 2023 Taler Systems SA
-
- Challenger 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
- Foundation; either version 3, or (at your option) any later version.
-
- Challenger 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
- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
- */
-/**
- * @file challengerdb/pg_challenge_get_address_and_stats.h
- * @brief implementation of the challenge_get_address_and_stats function for Postgres
- * @author Christian Grothoff
- */
-#ifndef PG_CHALLENGE_GET_ADDRESS_AND_STATS_H
-#define PG_CHALLENGE_GET_ADDRESS_AND_STATS_H
-
-#include <taler/taler_util.h>
-#include <taler/taler_json_lib.h>
-#include "challenger_database_plugin.h"
-
-
-/**
- * Get the user-provided address in a validation process and the
- * state of the process.
- *
- * @param cls closure
- * @param nonce unique nonce to use to identify the validation
- * @param[out] address the new address to be validated
- * @param[out] last_tx_time set to the last time when we (presumably) send a PIN to @a address, input should be current time to use if the existing value for tx_time is past @a next_tx_time
- * @param[out] pin_transmit set to true if we should transmit the @a last_pin to the @a address
- * @param[out] client_redirect_uri redirection URI of the client (for reporting failures)
- * @return transaction status:
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the nonce was found
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we did not find the nonce
- * #GNUNET_DB_STATUS_HARD_ERROR on failure
- */
-enum GNUNET_DB_QueryStatus
-CH_PG_challenge_get_address_and_stats (
- void *cls,
- const struct CHALLENGER_ValidationNonceP *nonce,
- json_t **address,
- struct GNUNET_TIME_Absolute *last_tx_time,
- uint32_t *auth_attempts_left,
- char **client_redirect_uri);
-
-#endif
diff --git a/src/challengerdb/plugin_challengerdb_postgres.c b/src/challengerdb/plugin_challengerdb_postgres.c
@@ -29,7 +29,6 @@
#include "pg_client_add.h"
#include "pg_client_modify.h"
#include "pg_client_delete.h"
-#include "pg_challenge_get_address_and_stats.h"
#include "pg_info_get_token.h"
#include "pg_token_add_token.h"
#include "pg_client_check.h"
@@ -399,8 +398,6 @@ libchallenger_plugin_db_postgres_init (void *cls)
= &CH_PG_client_check;
plugin->client_check2
= &CH_PG_client_check2;
- plugin->challenge_get_address_and_stats
- = &CH_PG_challenge_get_address_and_stats;
plugin->setup_nonce
= &CH_PG_setup_nonce;
plugin->authorize_start
diff --git a/src/include/challenger_database_plugin.h b/src/include/challenger_database_plugin.h
@@ -333,31 +333,6 @@ struct CHALLENGER_DatabasePlugin
/**
- * Get the user-provided address in a validation process and the
- * state of the process.
- *
- * @param cls closure
- * @param nonce unique nonce to use to identify the validation
- * @param[out] address the new address to be validated
- * @param[out] last_tx_time set to the last time when we (presumably) send a PIN to @a address, input should be current time to use if the existing value for tx_time is past @a next_tx_time
- * @param[out] pin_transmit set to true if we should transmit the @a last_pin to the @a address
- * @param[out] client_redirect_uri redirection URI of the client (for reporting failures)
- * @return transaction status:
- * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the nonce was found
- * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we did not find the nonce
- * #GNUNET_DB_STATUS_HARD_ERROR on failure
- */
- enum GNUNET_DB_QueryStatus
- (*challenge_get_address_and_stats)(
- void *cls,
- const struct CHALLENGER_ValidationNonceP *nonce,
- json_t **address,
- struct GNUNET_TIME_Absolute *last_tx_time,
- uint32_t *auth_attempts_left,
- char **client_redirect_uri);
-
-
- /**
* Check PIN entered to validate an address.
*
* @param cls