do_challenge_address.h (4851B)
1 /* 2 This file is part of Challenger 3 Copyright (C) 2023 Taler Systems SA 4 5 Challenger is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 Challenger is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file src/include/challenger-database/do_challenge_address.h 18 * @brief implementation of the do_challenge_address function for Postgres 19 * @author Christian Grothoff 20 */ 21 #ifndef CHALLENGER_DATABASE_DO_CHALLENGE_ADDRESS_H 22 #define CHALLENGER_DATABASE_DO_CHALLENGE_ADDRESS_H 23 24 #include <taler/taler_util.h> 25 #include <taler/taler_json_lib.h> 26 #include "challenger_util.h" 27 #include "challenger_database_lib.h" 28 29 30 /** 31 * Set the user-provided address in a validation process. Updates 32 * the address and decrements the "addresses left" counter. If the 33 * address did not change, the operation is successful even without 34 * the counter change. 35 * 36 * Note that a newly generated PIN is only stored as *pending*: it does not 37 * become the PIN we accept until 38 * #CHALLENGERDB_do_challenge_address_confirm_pin() is called, so that a 39 * failed transmission does not invalidate a PIN the user already holds. 40 * 41 * @param cls 42 * @param nonce unique nonce to use to identify the validation 43 * @param address the new address to validate 44 * @param retransmission_frequency minimum time that must have passed since the 45 * last transmission before the PIN is (re)transmitted to @a address again 46 * @param[in,out] tan set to the PIN/TAN last send to @a address, input should be random PIN/TAN to use if address did not change 47 * @param[out] state set to client's OAuth2 state if available 48 * @param[out] last_tx_time set to the last time when we (presumably) send a PIN to @a address 49 * @param[out] pin_transmit set to true if we should transmit the @a last_pin to the @a address 50 * @param[out] auth_attempts_left set to number of attempts the user has left on this pin 51 * @param[out] pin_transmissions_left set to number of times a PIN may still be 52 * transmitted for this validation; 0 means the user cannot request 53 * another PIN, while @a auth_attempts_left being 0 only means that the 54 * guesses on the *current* PIN are used up 55 * @param[out] client_redirect_uri redirection URI of the client (for reporting failures) 56 * @param[out] address_refused set to true if the address was refused (address change attempts exhausted) 57 * @param[out] solved set to true if the challenge is already solved 58 * @return transaction status: 59 * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the validation @a nonce exists 60 * (inspect @a address_refused / @a solved / @a pin_transmit for the actual 61 * outcome) 62 * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the validation @a nonce is unknown 63 * #GNUNET_DB_STATUS_HARD_ERROR on failure 64 */ 65 enum GNUNET_DB_QueryStatus 66 CHALLENGERDB_do_challenge_address ( 67 struct CHALLENGERDB_PostgresContext *ctx, 68 const struct CHALLENGER_ValidationNonceP *nonce, 69 const json_t *address, 70 struct GNUNET_TIME_Relative retransmission_frequency, 71 uint32_t *tan, 72 char **state, 73 struct GNUNET_TIME_Absolute *last_tx_time, 74 uint32_t *auth_attempts_left, 75 uint32_t *pin_transmissions_left, 76 bool *pin_transmit, 77 char **client_redirect_uri, 78 bool *address_refused, 79 bool *solved); 80 81 82 /** 83 * Confirm that the PIN generated by the last 84 * #CHALLENGERDB_do_challenge_address() call was actually transmitted to the 85 * address, and thus make it the PIN we accept from the user. Also resets 86 * the number of authentication attempts the user has on the new PIN. 87 * 88 * Must only be called once the transmission helper terminated successfully; 89 * if it is never called, the previous PIN (if any) remains valid. 90 * 91 * @param ctx database context to use 92 * @param nonce unique nonce identifying the validation 93 * @param[out] auth_attempts_left set to the number of attempts the user has 94 * on the now-current PIN 95 * @return transaction status: 96 * #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the PIN was promoted 97 * #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if there was no pending PIN, or the 98 * validation is unknown or already solved 99 * #GNUNET_DB_STATUS_HARD_ERROR on failure 100 */ 101 enum GNUNET_DB_QueryStatus 102 CHALLENGERDB_do_challenge_address_confirm_pin ( 103 struct CHALLENGERDB_PostgresContext *ctx, 104 const struct CHALLENGER_ValidationNonceP *nonce, 105 uint32_t *auth_attempts_left); 106 107 #endif