gnunet-svn
[Top][All Lists]
Advanced

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

[taler-challenger] branch master updated: make challenger-admin idempote


From: gnunet
Subject: [taler-challenger] branch master updated: make challenger-admin idempotent
Date: Fri, 22 Nov 2024 19:59:06 +0100

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

grothoff pushed a commit to branch master
in repository challenger.

The following commit(s) were added to refs/heads/master by this push:
     new 3186e3c  make challenger-admin idempotent
3186e3c is described below

commit 3186e3c49e456f0389101904a4cdcc6861c604cd
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Nov 22 19:58:58 2024 +0100

    make challenger-admin idempotent
---
 src/challenger/challenger-admin.c               | 24 +++++++++++++++++++
 src/challengerdb/pg_client_check.c              | 31 +++++++++++++++++++++++++
 src/challengerdb/pg_client_check.h              | 16 +++++++++++++
 src/challengerdb/plugin_challengerdb_postgres.c |  2 ++
 src/include/challenger_database_plugin.h        | 16 +++++++++++++
 5 files changed, 89 insertions(+)

diff --git a/src/challenger/challenger-admin.c 
b/src/challenger/challenger-admin.c
index 74a84f2..e9bf3b8 100644
--- a/src/challenger/challenger-admin.c
+++ b/src/challenger/challenger-admin.c
@@ -183,6 +183,30 @@ run (void *cls,
     enum GNUNET_DB_QueryStatus qs;
     uint64_t row_id;
 
+    qs = plugin->client_check2 (plugin->cls,
+                                redirect_uri,
+                                client_secret,
+                                &row_id);
+    switch (qs)
+    {
+    case GNUNET_DB_STATUS_SOFT_ERROR:
+    case GNUNET_DB_STATUS_HARD_ERROR:
+      GNUNET_break (0);
+      global_ret = EXIT_FAILURE;
+      goto cleanup;
+    case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
+      break;
+    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
+      if (be_quiet)
+        fprintf (stdout,
+                 "%llu\n",
+                 (unsigned long long) row_id);
+      else
+        fprintf (stdout,
+                 "Client added. Client ID is: %llu\n",
+                 (unsigned long long) row_id);
+      goto cleanup;
+    }
     qs = plugin->client_add (plugin->cls,
                              redirect_uri,
                              client_secret,
diff --git a/src/challengerdb/pg_client_check.c 
b/src/challengerdb/pg_client_check.c
index 0167b14..8013d37 100644
--- a/src/challengerdb/pg_client_check.c
+++ b/src/challengerdb/pg_client_check.c
@@ -61,3 +61,34 @@ CH_PG_client_check (void *cls,
                                                    params,
                                                    rs);
 }
+
+
+enum GNUNET_DB_QueryStatus
+CH_PG_client_check2 (void *cls,
+                     const char *client_uri,
+                     const char *client_secret,
+                     uint64_t *client_id)
+{
+  struct PostgresClosure *pg = cls;
+  struct GNUNET_PQ_QueryParam params[] = {
+    GNUNET_PQ_query_param_string (client_uri),
+    GNUNET_PQ_query_param_string (client_secret),
+    GNUNET_PQ_query_param_end
+  };
+  struct GNUNET_PQ_ResultSpec rs[] = {
+    GNUNET_PQ_result_spec_uint64 ("client_serial_id",
+                                  client_id),
+    GNUNET_PQ_result_spec_end
+  };
+
+  PREPARE (pg,
+           "client_check2",
+           "SELECT client_serial_id"
+           " FROM clients"
+           " WHERE uri=$1"
+           "   AND client_secret=$2;");
+  return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
+                                                   "client_check2",
+                                                   params,
+                                                   rs);
+}
diff --git a/src/challengerdb/pg_client_check.h 
b/src/challengerdb/pg_client_check.h
index 8fa39eb..fabd6b6 100644
--- a/src/challengerdb/pg_client_check.h
+++ b/src/challengerdb/pg_client_check.h
@@ -45,4 +45,20 @@ CH_PG_client_check (void *cls,
                     uint32_t counter_increment,
                     char **client_url);
 
+
+/**
+ * Check if a client is in the list of authorized clients.
+ *
+ * @param cls
+ * @param client_url client redirect URL (if known)
+ * @param client_secret secret of the client
+ * @param[out] set to client_id ID of the client if found
+ * @return transaction status
+ */
+enum GNUNET_DB_QueryStatus
+CH_PG_client_check2 (void *cls,
+                     const char *client_url,
+                     const char *client_secret,
+                     uint64_t *client_id);
+
 #endif
diff --git a/src/challengerdb/plugin_challengerdb_postgres.c 
b/src/challengerdb/plugin_challengerdb_postgres.c
index 37f1f7f..6be41de 100644
--- a/src/challengerdb/plugin_challengerdb_postgres.c
+++ b/src/challengerdb/plugin_challengerdb_postgres.c
@@ -396,6 +396,8 @@ libchallenger_plugin_db_postgres_init (void *cls)
     = &CH_PG_client_delete;
   plugin->client_check
     = &CH_PG_client_check;
+  plugin->client_check2
+    = &CH_PG_client_check2;
   plugin->setup_nonce
     = &CH_PG_setup_nonce;
   plugin->authorize_start
diff --git a/src/include/challenger_database_plugin.h 
b/src/include/challenger_database_plugin.h
index d6d8693..6bfecc1 100644
--- a/src/include/challenger_database_plugin.h
+++ b/src/include/challenger_database_plugin.h
@@ -215,6 +215,22 @@ struct CHALLENGER_DatabasePlugin
                     char **client_url);
 
 
+  /**
+   * Check if a client is in the list of authorized clients.
+   *
+   * @param cls
+   * @param client_url client redirect URL (if known)
+   * @param client_secret secret of the client
+   * @param[out] set to client_id ID of the client if found
+   * @return transaction status
+   */
+  enum GNUNET_DB_QueryStatus
+    (*client_check2)(void *cls,
+                     const char *client_url,
+                     const char *client_secret,
+                     uint64_t *client_id);
+
+
   /**
    * Start validation process by setting up a validation entry. Allows
    * the respective user who learns the @a nonce to later begin the

-- 
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]