challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit e791f3da5cc17a0e839be21c8f192b94a2cac5cc
parent 3a25f738f56e0d650701924755f9d3beb2735ca4
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 31 May 2026 14:11:10 +0200

DCE

Diffstat:
Dsrc/challengerdb/validate_login_address.c | 83-------------------------------------------------------------------------------
Dsrc/challengerdb/validate_login_pin.c | 56--------------------------------------------------------
Dsrc/include/challenger-database/validate_login_address.h | 60------------------------------------------------------------
Dsrc/include/challenger-database/validate_login_pin.h | 49-------------------------------------------------
4 files changed, 0 insertions(+), 248 deletions(-)

diff --git a/src/challengerdb/validate_login_address.c b/src/challengerdb/validate_login_address.c @@ -1,83 +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 src/challengerdb/validate_login_address.c - * @brief Implementation of the validate_login_address 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 "validate_login_address.h" -#include "pg_helper.h" - - -enum GNUNET_DB_QueryStatus -CHALLENGERDB_validate_login_address (struct CHALLENGERDB_PostgresContext *ctx, - const struct CHALLENGER_ValidationNonceP *nonce, - const char *address, - const char *client_scope, - const char *client_state, - const char *client_redirect_uri, - struct GNUNET_TIME_Absolute *last_tx_time, - uint32_t *last_pin, - uint32_t *pin_attempts_left) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (nonce), - GNUNET_PQ_query_param_string (address), - GNUNET_PQ_query_param_string (client_scope), - GNUNET_PQ_query_param_string (client_state), - NULL != client_redirect_uri - ? GNUNET_PQ_query_param_string (client_redirect_uri) - : GNUNET_PQ_query_param_null (), - GNUNET_PQ_query_param_end - }; - struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_absolute_time ("last_tx_time", - last_tx_time), - GNUNET_PQ_result_spec_uint32 ("last_pin", - last_pin), - GNUNET_PQ_result_spec_uint32 ("pin_attempts_left", - pin_attempts_left), - GNUNET_PQ_result_spec_end - }; - - PREPARE (ctx, - "validate_set_address", - "UPDATE validations SET" - " address_attempts_left=CASE" - " WHEN address != $2" - " THEN address_attempts_left - 1" - " ELSE address_attempts_left" - " END" - " ,address=$2" - " ,client_scope=$3" - " ,client_state=$4" - " ,client_redirect_uri=$5" - " WHERE nonce=$1" - " AND (address_attempts_left > 0" - " OR address == $2)" - " RETURNING" - " last_tx_time" - " ,last_pin" - " ,pin_attempts_left;"); - return GNUNET_PQ_eval_prepared_singleton_select (ctx->conn, - "validate_set_address", - params, - rs); -} diff --git a/src/challengerdb/validate_login_pin.c b/src/challengerdb/validate_login_pin.c @@ -1,56 +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 src/challengerdb/validate_login_pin.c - * @brief Implementation of the validate_login_pin 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 "validate_login_pin.h" -#include "pg_helper.h" - - -enum GNUNET_DB_QueryStatus -CHALLENGERDB_validate_login_pin (struct CHALLENGERDB_PostgresContext *ctx, - const struct CHALLENGER_ValidationNonceP *nonce, - struct GNUNET_TIME_Absolute tx_time, - uint32_t new_pin, - uint32_t auth_attempts_allowed) -{ - struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_auto_from_type (nonce), - GNUNET_PQ_query_param_absolute_time (&tx_time), - GNUNET_PQ_query_param_uint32 (&new_pin), - GNUNET_PQ_query_param_uint32 (&auth_attempts_allowed), - GNUNET_PQ_query_param_end - }; - - PREPARE (ctx, - "validate_login_set_pin", - "UPDATE validations SET" - " last_tx_time=$2" - " ,last_pin=$3" - " ,auth_attempts_left=$4" - " ,pin_attempts_left=pin_attempts_left - 1" - " WHERE nonce=$1" - " AND pin_attempts_left > 0;"); - return GNUNET_PQ_eval_prepared_non_select (ctx->conn, - "validate_login_set_pin", - params); -} diff --git a/src/include/challenger-database/validate_login_address.h b/src/include/challenger-database/validate_login_address.h @@ -1,60 +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 src/include/challenger-database/validate_login_address.h - * @brief implementation of the validate_login_address function for Postgres - * @author Christian Grothoff - */ -#ifndef CHALLENGER_DATABASE_VALIDATE_LOGIN_ADDRESS_H -#define CHALLENGER_DATABASE_VALIDATE_LOGIN_ADDRESS_H - -#include <taler/taler_util.h> -#include <taler/taler_json_lib.h> - -struct CHALLENGERDB_PostgresContext; -/** - * Set the user-provided address in a validation process. Updates - * the address and decrements the "addresses left" counter. If the - * address did not change, the operation is successful even without - * the counter change. - * - * @param cls - * @param nonce unique nonce to use to identify the validation - * @param address the new address to validate - * @param client_scope scope of the validation - * @param client_state state of the client - * @param client_redirect_uri where to redirect at the end, NULL to use a unique one registered for the client - * @param[out] last_tx_time set to the last time when we (presumably) send a PIN to @a address; 0 if never sent - * @param[out] last_pin set to the PIN last send to @a address, 0 if never sent - * @param[in,out] pin_attempts_left set to number of PIN transmission attempts left for this address; input is value to be used if address is new, output is possibly different if address was not new - * @return transaction status: - * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the address was changed - * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we do not permit further changes to the address (attempts exhausted) - * #GNUNET_DB_STATUS_HARD_ERROR on failure - */ -enum GNUNET_DB_QueryStatus -CHALLENGERDB_validate_login_address (struct CHALLENGERDB_PostgresContext *ctx, - const struct CHALLENGER_ValidationNonceP *nonce, - const char *address, - const char *client_scope, - const char *client_state, - const char *client_redirect_uri, - struct GNUNET_TIME_Absolute *last_tx_time, - uint32_t *last_pin, - uint32_t *pin_attempts_left); - - -#endif diff --git a/src/include/challenger-database/validate_login_pin.h b/src/include/challenger-database/validate_login_pin.h @@ -1,49 +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 src/include/challenger-database/validate_login_pin.h - * @brief implementation of the validate_login_pin function for Postgres - * @author Christian Grothoff - */ -#ifndef CHALLENGER_DATABASE_VALIDATE_LOGIN_PIN_H -#define CHALLENGER_DATABASE_VALIDATE_LOGIN_PIN_H - -#include <taler/taler_util.h> -#include <taler/taler_json_lib.h> - -struct CHALLENGERDB_PostgresContext; -/** - * Store a new PIN to be used to validate an address. - * - * @param cls - * @param nonce unique nonce to use to identify the validation - * @param tx_time the current time - * @param new_pin the PIN we are sending - * @param auth_attempts_allowed how many attempts do we give to the user to enter the correct PIN - * @return transaction status: - * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the pin was stored - * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if we do not know the @a nonce or if pin attempts left is zero - * #GNUNET_DB_STATUS_HARD_ERROR on failure - */ -enum GNUNET_DB_QueryStatus -CHALLENGERDB_validate_login_pin (struct CHALLENGERDB_PostgresContext *ctx, - const struct CHALLENGER_ValidationNonceP *nonce, - struct GNUNET_TIME_Absolute tx_time, - uint32_t new_pin, - uint32_t auth_attempts_allowed); - - -#endif