gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-challenger] branch master updated (93ac72e -> 93194d9)


From: gnunet
Subject: [taler-challenger] branch master updated (93ac72e -> 93194d9)
Date: Tue, 02 Jul 2024 14:41:50 +0200

This is an automated email from the git hooks/post-receive script.

sebasjm pushed a change to branch master
in repository challenger.

    from 93ac72e  bump for v0.11.0
     new 56385d9  reply with json in /solve and oauth error
     new 1d99fd2  missing solved status
     new 9d9a2fb  use TOO_MANY_REQUEST http status
     new 56c0bfd  client state may be NULL if no login was perform first
     new 59c4c4f  more info in the login endpoint
     new d1f31b5  implement missing v2 interface, remove unused fields
     new 93194d9  remove 428 which is not documented and the normal response 
gives enough info to the client

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/challenger/challenger-httpd_authorize.c        |  38 ++++----
 src/challenger/challenger-httpd_challenge.c        |  59 ++++++++----
 src/challenger/challenger-httpd_common.c           |  50 +++++++---
 src/challenger/challenger-httpd_config.c           |   6 +-
 src/challenger/challenger-httpd_solve.c            | 104 +++++++++++++--------
 ...challenger_do_challenge_set_address_and_pin.sql |  13 ++-
 .../challenger_do_validate_and_solve_pin.sql       |  10 +-
 src/challengerdb/pg_authorize_start.c              |  12 ++-
 src/challengerdb/pg_authorize_start.h              |   6 +-
 .../pg_challenge_set_address_and_pin.c             |   6 +-
 .../pg_challenge_set_address_and_pin.h             |   4 +-
 src/include/challenger_database_plugin.h           |  10 +-
 12 files changed, 219 insertions(+), 99 deletions(-)

diff --git a/src/challenger/challenger-httpd_authorize.c 
b/src/challenger/challenger-httpd_authorize.c
index 68015ac..5b7d8c8 100644
--- a/src/challenger/challenger-httpd_authorize.c
+++ b/src/challenger/challenger-httpd_authorize.c
@@ -185,6 +185,9 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
     uint32_t address_attempts_left;
     uint32_t pin_transmissions_left;
     uint32_t auth_attempts_left;
+    struct GNUNET_TIME_Absolute last_tx_time;
+
+    bool solved;
     enum GNUNET_DB_QueryStatus qs;
 
     /* authorize_start will return 0 if a 'redirect_uri' was
@@ -198,7 +201,9 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
                                  &last_address,
                                  &address_attempts_left,
                                  &pin_transmissions_left,
-                                 &auth_attempts_left);
+                                 &auth_attempts_left,
+                                 &solved,
+                                 &last_tx_time);
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
@@ -227,21 +232,6 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
     case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
       break;
     }
-    if ( (0 == address_attempts_left) &&
-         (0 == pin_transmissions_left) &&
-         (0 == auth_attempts_left) )
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                  "Refusing authorization: zero attempts left\n");
-      json_decref (last_address);
-      return TALER_MHD_redirect_with_oauth_status (
-        hc->connection,
-        redirect_uri,
-        state,
-        "unauthorized_client",
-        "client exceeded authorization attempts limit (too many addresses)",
-        NULL);
-    }
     {
       enum GNUNET_GenericReturnValue ret;
       json_t *args;
@@ -254,16 +244,22 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
                        "enter-%s-form",
                        CH_address_type);
       args = GNUNET_JSON_PACK (
-        GNUNET_JSON_pack_allow_null (
-          GNUNET_JSON_pack_object_incref ("restrictions",
-                                          CH_restrictions)),
         GNUNET_JSON_pack_bool ("fix_address",
                                0 == address_attempts_left),
-        GNUNET_JSON_pack_string ("nonce",
-                                 hc->path),
         GNUNET_JSON_pack_allow_null (
           GNUNET_JSON_pack_object_steal ("last_address",
                                          last_address)),
+        GNUNET_JSON_pack_bool ("solved",
+                               solved),
+        GNUNET_JSON_pack_uint64 ("pin_transmissions_left",
+                                 pin_transmissions_left),
+        GNUNET_JSON_pack_uint64 ("auth_attempts_left",
+                                 auth_attempts_left),
+        GNUNET_JSON_pack_timestamp ("retransmission_time",
+                                    GNUNET_TIME_absolute_to_timestamp(
+                                      GNUNET_TIME_absolute_add (
+                                        last_tx_time,
+                                        CH_validation_duration))),
         GNUNET_JSON_pack_uint64 ("changes_left",
                                  address_attempts_left)
         );
diff --git a/src/challenger/challenger-httpd_challenge.c 
b/src/challenger/challenger-httpd_challenge.c
index c5fed98..be900c6 100644
--- a/src/challenger/challenger-httpd_challenge.c
+++ b/src/challenger/challenger-httpd_challenge.c
@@ -152,6 +152,11 @@ struct ChallengeContext
    */
   bool retransmit;
 
+  /**
+   * Is the challenge already solved?
+   */
+  bool solved;
+
   /**
    * Did we do the DB interaction?
    */
@@ -653,7 +658,8 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
       &bc->pin_attempts_left,
       &bc->retransmit,
       &bc->client_redirect_uri,
-      &bc->address_refused);
+      &bc->address_refused,
+      &bc->solved);
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
@@ -677,29 +683,46 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
       break;
     }
     bc->db_finished = true;
+    if (bc->solved)
+    {
+      struct MHD_Response *response;
+      MHD_RESULT ret;
+
+      json_t *args = GNUNET_JSON_PACK (
+        GNUNET_JSON_pack_string ("type",
+                                 "completed"),
+        GNUNET_JSON_pack_string ("redirect_url",
+                                 bc->client_redirect_uri)
+        );
+
+      response = TALER_MHD_make_json (args);
+
+      ret = MHD_queue_response (hc->connection,
+                                MHD_HTTP_OK,
+                                response);
+      MHD_destroy_response (response);
+      return ret;
+    }
     if (bc->address_refused)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Address changes exhausted address change limit for this 
process\n");
-      return TALER_MHD_redirect_with_oauth_status (
-        hc->connection,
-        bc->client_redirect_uri,
-        bc->state,
-        "unauthorized_client",
-        "client exceeded authorization attempts limit (too many addresses 
attempted)",
-        NULL);
+      return reply_error (bc,
+                          "unauthorized_client",
+                          MHD_HTTP_TOO_MANY_REQUESTS,
+                          TALER_EC_CHALLENGER_TOO_MANY_ATTEMPTS,
+                          "client exceeded authorization attempts limit (too 
many addresses attempted)");
+
     }
     if (0 == bc->pin_attempts_left)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                   "Address changes exhausted PIN limit for this address\n");
-      return TALER_MHD_redirect_with_oauth_status (
-        hc->connection,
-        bc->client_redirect_uri,
-        bc->state,
-        "unauthorized_client",
-        "client exceeded authorization attempts limit (too many PINs)",
-        NULL);
+      return reply_error (bc,
+                          "unauthorized_client",
+                          MHD_HTTP_TOO_MANY_REQUESTS,
+                          TALER_EC_CHALLENGER_TOO_MANY_ATTEMPTS,
+                          "client exceeded authorization attempts limit (too 
many PINs)");
     }
 
     if (bc->retransmit)
@@ -730,12 +753,14 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
                                bc->pin_attempts_left),
       GNUNET_JSON_pack_string ("nonce",
                                hc->path),
+      GNUNET_JSON_pack_string ("type",
+                               "created"),
       GNUNET_JSON_pack_object_incref ("address",
                                       bc->address),
       GNUNET_JSON_pack_bool ("transmitted",
                              bc->retransmit),
-      GNUNET_JSON_pack_string ("next_tx_time",
-                               GNUNET_TIME_absolute2s (
+      GNUNET_JSON_pack_timestamp ("retransmission_time",
+                                  GNUNET_TIME_absolute_to_timestamp(
                                  GNUNET_TIME_absolute_add (
                                    bc->last_tx_time,
                                    CH_validation_duration)))
diff --git a/src/challenger/challenger-httpd_common.c 
b/src/challenger/challenger-httpd_common.c
index 65fbfa5..17b2b6e 100644
--- a/src/challenger/challenger-httpd_common.c
+++ b/src/challenger/challenger-httpd_common.c
@@ -188,21 +188,23 @@ TALER_MHD_redirect_with_oauth_status (
   const char *oauth_error_uri)
 {
   struct MHD_Response *response;
+  unsigned int http_status;
 
-  response = MHD_create_response_from_buffer (strlen (oauth_error),
-                                              (void *) oauth_error,
-                                              MHD_RESPMEM_PERSISTENT);
-  if (NULL == response)
-  {
-    GNUNET_break (0);
-    return MHD_NO;
-  }
-  TALER_MHD_add_global_headers (response);
-  GNUNET_break (MHD_YES ==
-                MHD_add_response_header (response,
-                                         MHD_HTTP_HEADER_CONTENT_TYPE,
-                                         "text/plain"));
+  if (0 == CH_get_output_type (connection))
   {
+    response = MHD_create_response_from_buffer (strlen (oauth_error),
+                                                (void *) oauth_error,
+                                                MHD_RESPMEM_PERSISTENT);
+    if (NULL == response)
+    {
+      GNUNET_break (0);
+      return MHD_NO;
+    }
+    TALER_MHD_add_global_headers (response);
+    GNUNET_break (MHD_YES ==
+                  MHD_add_response_header (response,
+                                          MHD_HTTP_HEADER_CONTENT_TYPE,
+                                          "text/plain"));
     char *url;
     char *enc_err;
     char *enc_state;
@@ -237,14 +239,34 @@ TALER_MHD_redirect_with_oauth_status (
       GNUNET_free (url);
       return MHD_NO;
     }
+    http_status = MHD_HTTP_FOUND;
     GNUNET_free (url);
   }
+  else
+  {
+    json_t *args;
+    args = GNUNET_JSON_PACK (
+      GNUNET_JSON_pack_string ("state",
+                               state),
+      GNUNET_JSON_pack_string ("error",
+                               oauth_error),
+      GNUNET_JSON_pack_allow_null (
+        GNUNET_JSON_pack_string ("description",
+                                 oauth_error_description)),
+      GNUNET_JSON_pack_allow_null (
+        GNUNET_JSON_pack_string ("uri",
+                                 oauth_error_uri)));
+
+    response = TALER_MHD_make_json (args);
+    TALER_MHD_add_global_headers (response);
+    http_status = MHD_HTTP_TOO_MANY_REQUESTS;
+  }
 
   {
     MHD_RESULT ret;
 
     ret = MHD_queue_response (connection,
-                              MHD_HTTP_FOUND,
+                              http_status,
                               response);
     MHD_destroy_response (response);
     return ret;
diff --git a/src/challenger/challenger-httpd_config.c 
b/src/challenger/challenger-httpd_config.c
index da6533f..575d035 100644
--- a/src/challenger/challenger-httpd_config.c
+++ b/src/challenger/challenger-httpd_config.c
@@ -68,8 +68,12 @@ CH_handler_config (struct CH_HandlerContext *hc,
                                "urn:net:taler:specs:challenger:c-reference"),
       GNUNET_JSON_pack_string ("name",
                                "challenger"),
+      GNUNET_JSON_pack_string ("address_type",
+                               CH_address_type),
+      GNUNET_JSON_pack_object_incref ("restrictions",
+                                      CH_restrictions),
       GNUNET_JSON_pack_string ("version",
-                               "1:1:1"));
+                               "2:0:0"));
     GNUNET_break (MHD_YES ==
                   MHD_add_response_header (response,
                                            MHD_HTTP_HEADER_EXPIRES,
diff --git a/src/challenger/challenger-httpd_solve.c 
b/src/challenger/challenger-httpd_solve.c
index 15495bb..d9c865c 100644
--- a/src/challenger/challenger-httpd_solve.c
+++ b/src/challenger/challenger-httpd_solve.c
@@ -317,13 +317,11 @@ CH_handler_solve (struct CH_HandlerContext *hc,
       {
         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                     "Client exhausted all chances to satisfy challenge\n");
-        return TALER_MHD_redirect_with_oauth_status (
-          hc->connection,
-          bc->client_redirect_uri,
-          bc->state,
-          "access_denied",
-          "users exhausted all possibilities of passing the check",
-          NULL);
+        return reply_error (bc,
+                            "access_denied",
+                            MHD_HTTP_TOO_MANY_REQUESTS,
+                            TALER_EC_CHALLENGER_TOO_MANY_ATTEMPTS,
+                            "users exhausted all possibilities of passing the 
check");
       }
 
       GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -332,6 +330,8 @@ CH_handler_solve (struct CH_HandlerContext *hc,
         TALER_JSON_pack_ec (TALER_EC_CHALLENGER_INVALID_PIN),
         GNUNET_JSON_pack_uint64 ("addresses_left",
                                  bc->addr_left),
+        GNUNET_JSON_pack_string ("type",
+                                 "pending"),
         GNUNET_JSON_pack_uint64 ("pin_transmissions_left",
                                  bc->pin_transmissions_left),
         GNUNET_JSON_pack_uint64 ("auth_attempts_left",
@@ -360,6 +360,7 @@ CH_handler_solve (struct CH_HandlerContext *hc,
   {
     struct MHD_Response *response;
     char *url;
+    unsigned int http_status;
 
     {
       char *client_secret;
@@ -406,13 +407,23 @@ CH_handler_solve (struct CH_HandlerContext *hc,
                                 client_scope,
                                 address,
                                 client_redirect_uri);
-        url_encoded = TALER_urlencode (client_state);
-        GNUNET_asprintf (&url,
-                         "%s?code=%s&state=%s",
-                         client_redirect_uri,
-                         code,
-                         url_encoded);
-        GNUNET_free (url_encoded);
+        if (NULL == client_state)
+        {
+          GNUNET_asprintf (&url,
+                          "%s?code=%s",
+                          client_redirect_uri,
+                          code);
+        }
+        else
+        {
+          url_encoded = TALER_urlencode (client_state);
+          GNUNET_asprintf (&url,
+                          "%s?code=%s&state=%s",
+                          client_redirect_uri,
+                          code,
+                          url_encoded);
+          GNUNET_free (url_encoded);
+        }
         GNUNET_free (code);
       }
       json_decref (address);
@@ -422,41 +433,60 @@ CH_handler_solve (struct CH_HandlerContext *hc,
       GNUNET_free (client_state);
     }
 
+    if (0 == CH_get_output_type (hc->connection))
     {
-      const char *ok = "Ok!";
+      {
+        const char *ok = "Ok!";
 
-      response = MHD_create_response_from_buffer (strlen (ok),
-                                                  (void *) ok,
-                                                  MHD_RESPMEM_PERSISTENT);
-    }
-    if (NULL == response)
-    {
-      GNUNET_break (0);
+        response = MHD_create_response_from_buffer (strlen (ok),
+                                                    (void *) ok,
+                                                    MHD_RESPMEM_PERSISTENT);
+      }
+      if (NULL == response)
+      {
+        GNUNET_break (0);
+        GNUNET_free (url);
+        return MHD_NO;
+      }
+      TALER_MHD_add_global_headers (response);
+      GNUNET_break (MHD_YES ==
+                    MHD_add_response_header (response,
+                                             MHD_HTTP_HEADER_CONTENT_TYPE,
+                                             "text/plain"));
+      if (MHD_NO ==
+          MHD_add_response_header (response,
+                                   MHD_HTTP_HEADER_LOCATION,
+                                   url))
+      {
+        GNUNET_break (0);
+        MHD_destroy_response (response);
+        GNUNET_free (url);
+        return MHD_NO;
+      }
+      http_status = MHD_HTTP_FOUND;
       GNUNET_free (url);
-      return MHD_NO;
     }
-    TALER_MHD_add_global_headers (response);
-    GNUNET_break (MHD_YES ==
-                  MHD_add_response_header (response,
-                                           MHD_HTTP_HEADER_CONTENT_TYPE,
-                                           "text/plain"));
-    if (MHD_NO ==
-        MHD_add_response_header (response,
-                                 MHD_HTTP_HEADER_LOCATION,
-                                 url))
+    else
     {
-      GNUNET_break (0);
-      MHD_destroy_response (response);
+      json_t *args;
+      args = GNUNET_JSON_PACK (
+        GNUNET_JSON_pack_string ("type",
+                                "completed"),
+        GNUNET_JSON_pack_string ("redirect_url",
+                                url)
+        );
       GNUNET_free (url);
-      return MHD_NO;
+
+      response = TALER_MHD_make_json (args);
+
+      http_status = MHD_HTTP_OK;
     }
-    GNUNET_free (url);
 
     {
       MHD_RESULT ret;
 
       ret = MHD_queue_response (hc->connection,
-                                MHD_HTTP_FOUND,
+                                http_status,
                                 response);
       MHD_destroy_response (response);
       return ret;
diff --git a/src/challengerdb/challenger_do_challenge_set_address_and_pin.sql 
b/src/challengerdb/challenger_do_challenge_set_address_and_pin.sql
index bbdf4b2..b5dbb17 100644
--- a/src/challengerdb/challenger_do_challenge_set_address_and_pin.sql
+++ b/src/challengerdb/challenger_do_challenge_set_address_and_pin.sql
@@ -28,7 +28,8 @@ CREATE OR REPLACE FUNCTION 
challenger_do_challenge_set_address_and_pin (
   OUT out_pin_transmit BOOLEAN,
   OUT out_auth_attempts_left INT4,
   OUT out_client_redirect_uri TEXT,
-  OUT out_address_refused BOOLEAN)
+  OUT out_address_refused BOOLEAN,
+  OUT out_solved BOOLEAN)
 LANGUAGE plpgsql
 AS $$
 DECLARE
@@ -59,6 +60,7 @@ THEN
   out_auth_attempts_left=0;
   out_client_redirect_uri=NULL;
   out_address_refused=TRUE;
+  out_solved=FALSE;
   out_state=NULL;
   RETURN;
 END IF;
@@ -70,6 +72,15 @@ out_auth_attempts_left=my_status.auth_attempts_left;
 out_state=my_status.client_state;
 out_client_redirect_uri=my_status.client_redirect_uri;
 
+IF ( 0 > my_status.auth_attempts_left ) -- this challenge is solved
+THEN
+  out_address_refused=TRUE;
+  out_solved=TRUE;
+  out_auth_attempts_left=0;
+  RETURN;
+END IF;
+out_solved=FALSE;
+
 IF ( (0 = my_status.address_attempts_left) AND
      (in_address != my_status.address) )
 THEN
diff --git a/src/challengerdb/challenger_do_validate_and_solve_pin.sql 
b/src/challengerdb/challenger_do_validate_and_solve_pin.sql
index 606835b..cbfb402 100644
--- a/src/challengerdb/challenger_do_validate_and_solve_pin.sql
+++ b/src/challengerdb/challenger_do_validate_and_solve_pin.sql
@@ -71,6 +71,14 @@ THEN
 END IF;
 out_no_challenge=FALSE;
 
+IF (0 > my_status.auth_attempts_left)
+THEN
+  out_solved=TRUE;
+  out_exhausted=TRUE;
+  out_auth_attempts_left=0;
+  RETURN;
+END IF;
+
 IF (0 = my_status.auth_attempts_left)
 THEN
   out_solved=FALSE;
@@ -85,7 +93,7 @@ IF NOT out_solved
 THEN
   out_auth_attempts_left=my_status.auth_attempts_left-1;
 ELSE
-  out_auth_attempts_left=0; -- solved: no more attempts
+  out_auth_attempts_left=-1; -- solved: no more attempts
 END IF;
 
 UPDATE validations
diff --git a/src/challengerdb/pg_authorize_start.c 
b/src/challengerdb/pg_authorize_start.c
index 7217e2b..8a6052b 100644
--- a/src/challengerdb/pg_authorize_start.c
+++ b/src/challengerdb/pg_authorize_start.c
@@ -36,7 +36,9 @@ CH_PG_authorize_start (void *cls,
                        json_t **last_address,
                        uint32_t *address_attempts_left,
                        uint32_t *pin_transmissions_left,
-                       uint32_t *auth_attempts_left)
+                       uint32_t *auth_attempts_left,
+                       bool *solved,
+                       struct GNUNET_TIME_Absolute *last_tx_time)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_QueryParam params[] = {
@@ -62,6 +64,10 @@ CH_PG_authorize_start (void *cls,
                                   pin_transmissions_left),
     GNUNET_PQ_result_spec_uint32 ("auth_attempts_left",
                                   auth_attempts_left),
+    GNUNET_PQ_result_spec_bool ("solved",
+                                solved),
+    GNUNET_PQ_result_spec_absolute_time ("last_tx_time",
+                                         last_tx_time),
     GNUNET_PQ_result_spec_end
   };
 
@@ -79,7 +85,9 @@ CH_PG_authorize_start (void *cls,
            "   address"
            "  ,address_attempts_left"
            "  ,pin_transmissions_left"
-           "  ,auth_attempts_left;");
+           "  ,GREATEST(0, auth_attempts_left) AS auth_attempts_left"
+           "  ,auth_attempts_left = -1 AS solved"
+           "  ,last_tx_time;");
   return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
                                                    
"authorize_start_validation",
                                                    params,
diff --git a/src/challengerdb/pg_authorize_start.h 
b/src/challengerdb/pg_authorize_start.h
index dceddb4..5592030 100644
--- a/src/challengerdb/pg_authorize_start.h
+++ b/src/challengerdb/pg_authorize_start.h
@@ -42,6 +42,8 @@
  * @param[out] address_attempts_left set to number of address changing 
attempts left for this address
  * @param[out] pin_transmissions_left set to number of times the PIN can still 
be re-requested
  * @param[out] auth_attempts_left set to number of authentication attempts 
remaining
+ * @param[out] solved set to true if the challenge is already solved
+ * @param[out] last_tx_time set to the last time when we (presumably) send a 
PIN to @a last_address; 0 if never sent
  * @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)
@@ -57,7 +59,9 @@ CH_PG_authorize_start (void *cls,
                        json_t **last_address,
                        uint32_t *address_attempts_left,
                        uint32_t *pin_transmissions_left,
-                       uint32_t *auth_attempts_left);
+                       uint32_t *auth_attempts_left,
+                       bool *solved,
+                       struct GNUNET_TIME_Absolute *last_tx_time);
 
 
 #endif
diff --git a/src/challengerdb/pg_challenge_set_address_and_pin.c 
b/src/challengerdb/pg_challenge_set_address_and_pin.c
index 3a44d6a..4347ff6 100644
--- a/src/challengerdb/pg_challenge_set_address_and_pin.c
+++ b/src/challengerdb/pg_challenge_set_address_and_pin.c
@@ -38,7 +38,8 @@ CH_PG_challenge_set_address_and_pin (
   uint32_t *auth_attempts_left,
   bool *pin_transmit,
   char **client_redirect_uri,
-  bool *address_refused)
+  bool *address_refused,
+  bool *solved)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_TIME_Absolute now
@@ -76,6 +77,8 @@ CH_PG_challenge_set_address_and_pin (
       NULL),
     GNUNET_PQ_result_spec_bool ("address_refused",
                                 address_refused),
+    GNUNET_PQ_result_spec_bool ("solved",
+                                solved),
     GNUNET_PQ_result_spec_end
   };
   enum GNUNET_DB_QueryStatus qs;
@@ -92,6 +95,7 @@ CH_PG_challenge_set_address_and_pin (
            ",out_auth_attempts_left AS auth_attempts_left"
            ",out_client_redirect_uri AS client_redirect_uri"
            ",out_address_refused AS address_refused"
+           ",out_solved AS solved"
            " FROM challenger_do_challenge_set_address_and_pin"
            " ($1,$2,$3,$4,$5);");
   qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
diff --git a/src/challengerdb/pg_challenge_set_address_and_pin.h 
b/src/challengerdb/pg_challenge_set_address_and_pin.h
index 9f2aea5..2cf1b31 100644
--- a/src/challengerdb/pg_challenge_set_address_and_pin.h
+++ b/src/challengerdb/pg_challenge_set_address_and_pin.h
@@ -43,6 +43,7 @@
  * @param[out] auth_attempts_left set to number of attempts the user has left 
on this pin
  * @param[out] client_redirect_uri redirection URI of the client (for 
reporting failures)
  * @param[out] address_refused set to true if the address was refused (address 
change attempts exhausted)
+ * @param[out] solved set to true if the challenge is already solved
  * @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)
@@ -60,6 +61,7 @@ CH_PG_challenge_set_address_and_pin (
   uint32_t *auth_attempts_left,
   bool *pin_transmit,
   char **client_redirect_uri,
-  bool *address_refused);
+  bool *address_refused,
+  bool *solved);
 
 #endif
diff --git a/src/include/challenger_database_plugin.h 
b/src/include/challenger_database_plugin.h
index 2e47d7f..17433c8 100644
--- a/src/include/challenger_database_plugin.h
+++ b/src/include/challenger_database_plugin.h
@@ -233,6 +233,8 @@ struct CHALLENGER_DatabasePlugin
    * @param[out] address_attempts_left set to number change address operations 
left for this @a nonce
    * @param[out] pin_transmissions_left set to number of times the PIN can 
still be re-requested
    * @param[out] auth_attempts_left set to number of authentication attempts 
remaining
+   * @param[out] solved set to true if the challenge is already solved
+   * @param[out] last_tx_time set to the last time when we (presumably) send a 
PIN to @a last_address; 0 if never sent
    * @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)
@@ -248,7 +250,9 @@ struct CHALLENGER_DatabasePlugin
                      json_t **last_address,
                      uint32_t *address_attempts_left,
                      uint32_t *pin_transmissions_left,
-                     uint32_t *auth_attempts_left);
+                     uint32_t *auth_attempts_left,
+                     bool *solved,
+                     struct GNUNET_TIME_Absolute *last_tx_time);
 
 
   /**
@@ -268,6 +272,7 @@ struct CHALLENGER_DatabasePlugin
    * @param[out] auth_attempts_left set to number of attempts the user has 
left on this pin
    * @param[out] client_redirect_uri redirection URI of the client (for 
reporting failures)
    * @param[out] address_refused set to true if the address was refused 
(address change attempts exhausted)
+   * @param[out] solved set to true if the challenge is already solved
    * @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)
@@ -285,7 +290,8 @@ struct CHALLENGER_DatabasePlugin
     uint32_t *auth_attempts_left,
     bool *pin_transmit,
     char **client_redirect_uri,
-    bool *address_refused);
+    bool *address_refused,
+    bool *solved);
 
 
   /**

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]