challenger

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

do_challenge_address.h (5063B)


      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 TAN is only stored as *pending*: it does not
     37  * become the TAN we accept until
     38  * #CHALLENGERDB_do_challenge_address_confirm_pin() is called, so that a
     39  * failed transmission does not invalidate a TAN 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 TAN is (re)transmitted to @a address again
     46  * @param[in,out] tan set to the TAN last send to @a address, input should be random 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 TAN 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 TAN may still be
     52  *        transmitted for this validation; 0 means the user cannot request
     53  *        another TAN, while @a auth_attempts_left being 0 only means that the
     54  *        guesses on the *current* TAN 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  * @param[out] failed set to true if the validation failed permanently: no
     59  *        address change, TAN transmission or TAN attempt is left, so it can
     60  *        never succeed anymore
     61  * @return transaction status:
     62  *   #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the validation @a nonce exists
     63  *     (inspect @a failed / @a address_refused / @a solved / @a pin_transmit for the actual
     64  *     outcome)
     65  *   #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the validation @a nonce is unknown
     66  *   #GNUNET_DB_STATUS_HARD_ERROR on failure
     67  */
     68 enum GNUNET_DB_QueryStatus
     69 CHALLENGERDB_do_challenge_address (
     70   struct CHALLENGERDB_PostgresContext *ctx,
     71   const struct CHALLENGER_ValidationNonceP *nonce,
     72   const json_t *address,
     73   struct GNUNET_TIME_Relative retransmission_frequency,
     74   uint32_t *tan,
     75   char **state,
     76   struct GNUNET_TIME_Absolute *last_tx_time,
     77   uint32_t *auth_attempts_left,
     78   uint32_t *pin_transmissions_left,
     79   bool *pin_transmit,
     80   char **client_redirect_uri,
     81   bool *address_refused,
     82   bool *solved,
     83   bool *failed);
     84 
     85 
     86 /**
     87  * Confirm that the TAN generated by the last
     88  * #CHALLENGERDB_do_challenge_address() call was actually transmitted to the
     89  * address, and thus make it the TAN we accept from the user.  Also resets
     90  * the number of authentication attempts the user has on the new TAN.
     91  *
     92  * Must only be called once the transmission helper terminated successfully;
     93  * if it is never called, the previous TAN (if any) remains valid.
     94  *
     95  * @param ctx database context to use
     96  * @param nonce unique nonce identifying the validation
     97  * @param[out] auth_attempts_left set to the number of attempts the user has
     98  *        on the now-current TAN
     99  * @return transaction status:
    100  *   #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the TAN was promoted
    101  *   #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if there was no pending TAN, or the
    102  *     validation is unknown, already solved or failed
    103  *   #GNUNET_DB_STATUS_HARD_ERROR on failure
    104  */
    105 enum GNUNET_DB_QueryStatus
    106 CHALLENGERDB_do_challenge_address_confirm_pin (
    107   struct CHALLENGERDB_PostgresContext *ctx,
    108   const struct CHALLENGER_ValidationNonceP *nonce,
    109   uint32_t *auth_attempts_left);
    110 
    111 #endif