LCOV - code coverage report
Current view: top level - challengerdb - get_validation_pkce.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 19 19
Test Date: 2026-09-09 01:07:11 Functions: 100.0 % 1 1

            Line data    Source code
       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/challengerdb/get_validation_pkce.c
      18              :  * @brief Implementation of the get_validation_pkce function for Postgres
      19              :  * @author Bohdan Potuzhnyi
      20              :  * @author Vlada Svirsh
      21              :  */
      22              : #include "platform.h"
      23              : #include <taler/taler_error_codes.h>
      24              : #include <taler/taler_dbevents.h>
      25              : #include <taler/taler_pq_lib.h>
      26              : #include "get_validation_pkce.h"
      27              : #include "pg_helper.h"
      28              : 
      29              : enum GNUNET_DB_QueryStatus
      30           10 : CHALLENGERDB_get_validation_pkce (
      31              :   struct CHALLENGERDB_PostgresContext *ctx,
      32              :   const struct CHALLENGER_ValidationNonceP *nonce,
      33              :   uint64_t client_id,
      34              :   char **client_secret,
      35              :   json_t **address,
      36              :   char **client_scope,
      37              :   char **client_state,
      38              :   char **client_redirect_uri,
      39              :   char **code_challenge,
      40              :   uint32_t *code_challenge_method)
      41              : {
      42              :   struct GNUNET_TIME_Absolute now
      43           10 :     = GNUNET_TIME_absolute_get ();
      44           10 :   struct GNUNET_PQ_QueryParam params[] = {
      45           10 :     GNUNET_PQ_query_param_auto_from_type (nonce),
      46           10 :     GNUNET_PQ_query_param_absolute_time (&now),
      47           10 :     GNUNET_PQ_query_param_uint64 (&client_id),
      48              :     GNUNET_PQ_query_param_end
      49              :   };
      50           10 :   struct GNUNET_PQ_ResultSpec rs[] = {
      51           10 :     GNUNET_PQ_result_spec_string ("client_secret",
      52              :                                   client_secret),
      53           10 :     GNUNET_PQ_result_spec_allow_null (
      54              :       TALER_PQ_result_spec_json ("address",
      55              :                                  address),
      56              :       NULL),
      57           10 :     GNUNET_PQ_result_spec_allow_null (
      58              :       GNUNET_PQ_result_spec_string ("client_scope",
      59              :                                     client_scope),
      60              :       NULL),
      61           10 :     GNUNET_PQ_result_spec_allow_null (
      62              :       GNUNET_PQ_result_spec_string ("client_state",
      63              :                                     client_state),
      64              :       NULL),
      65           10 :     GNUNET_PQ_result_spec_string ("redirect_uri",
      66              :                                   client_redirect_uri),
      67           10 :     GNUNET_PQ_result_spec_allow_null (
      68              :       GNUNET_PQ_result_spec_string ("code_challenge",
      69              :                                     code_challenge),
      70              :       NULL),
      71           10 :     GNUNET_PQ_result_spec_uint32 ("code_challenge_method",
      72              :                                   code_challenge_method),
      73              :     GNUNET_PQ_result_spec_end
      74              :   };
      75              : 
      76           10 :   *client_scope = NULL;
      77           10 :   *client_state = NULL;
      78           10 :   *address = NULL;
      79           10 :   PREPARE (ctx,
      80              :            "get_validation_pkce",
      81              :            "SELECT "
      82              :            "  client_secret"
      83              :            " ,address"
      84              :            " ,client_scope"
      85              :            " ,client_state"
      86              :            " ,COALESCE(client_redirect_uri,uri) AS redirect_uri"
      87              :            " ,code_challenge"
      88              :            " ,code_challenge_method"
      89              :            " FROM validations"
      90              :            " JOIN clients "
      91              :            "  USING (client_serial_id)"
      92              :            " WHERE nonce=$1"
      93              :            "   AND expiration_time > $2"
      94              :            "   AND client_serial_id=$3"
      95              :            /* -1 is the sentinel challenger_do_validate_and_solve_pin() writes
      96              :               once the correct TAN was entered; without this the /token endpoint
      97              :               would happily mint a token for a validation where the user never
      98              :               proved anything.  Must match the guard in do_insert_token.c. */
      99              :            "   AND auth_attempts_left < 0");
     100           10 :   return GNUNET_PQ_eval_prepared_singleton_select (ctx->conn,
     101              :                                                    "get_validation_pkce",
     102              :                                                    params,
     103              :                                                    rs);
     104              : }
        

Generated by: LCOV version 2.0-1