From d94a0fe2f979348b45289b66b1cb5f72c3c3e76c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 16 Aug 2021 16:44:00 +0200 Subject: -modify plugins to set 'satisfied' bit --- .../anastasis_authorization_plugin_email.c | 17 ++++++++++++++++- .../anastasis_authorization_plugin_file.c | 17 ++++++++++++++++- .../anastasis_authorization_plugin_post.c | 18 ++++++++++++++++-- src/authorization/anastasis_authorization_plugin_sms.c | 17 ++++++++++++++++- 4 files changed, 64 insertions(+), 5 deletions(-) (limited to 'src/authorization') diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c index 22a7824..3d42aa3 100644 --- a/src/authorization/anastasis_authorization_plugin_email.c +++ b/src/authorization/anastasis_authorization_plugin_email.c @@ -24,6 +24,8 @@ #include #include #include "anastasis_util_lib.h" +#include +#include "anastasis_database_lib.h" /** @@ -248,7 +250,20 @@ email_start (void *cls, { struct Email_Context *ctx = cls; struct ANASTASIS_AUTHORIZATION_State *as; - + enum GNUNET_DB_QueryStatus qs; + + /* If the user can show this challenge code, this + plugin is already happy (no additional + requirements), so mark this challenge as + already satisfied from the start. */ + qs = ctx->ac->db->mark_challenge_code_satisfied (ctx->ac->db->cls, + truth_uuid, + code); + if (qs <= 0) + { + GNUNET_break (0); + return NULL; + } as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State); as->trigger = trigger; as->trigger_cls = trigger_cls; diff --git a/src/authorization/anastasis_authorization_plugin_file.c b/src/authorization/anastasis_authorization_plugin_file.c index 38939a0..db9dc67 100644 --- a/src/authorization/anastasis_authorization_plugin_file.c +++ b/src/authorization/anastasis_authorization_plugin_file.c @@ -21,6 +21,8 @@ #include "platform.h" #include "anastasis_authorization_plugin.h" #include +#include +#include "anastasis_database_lib.h" /** @@ -125,7 +127,20 @@ file_start (void *cls, { const struct ANASTASIS_AuthorizationContext *ac = cls; struct ANASTASIS_AUTHORIZATION_State *as; - + enum GNUNET_DB_QueryStatus qs; + + /* If the user can show this challenge code, this + plugin is already happy (no additional + requirements), so mark this challenge as + already satisfied from the start. */ + qs = ac->db->mark_challenge_code_satisfied (ac->db->cls, + truth_uuid, + code); + if (qs <= 0) + { + GNUNET_break (0); + return NULL; + } as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State); as->cls = cls; as->truth_uuid = *truth_uuid; diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c index dddd273..30cea88 100644 --- a/src/authorization/anastasis_authorization_plugin_post.c +++ b/src/authorization/anastasis_authorization_plugin_post.c @@ -24,7 +24,8 @@ #include #include #include "anastasis_util_lib.h" - +#include +#include "anastasis_database_lib.h" /** * Saves the State of a authorization plugin. @@ -277,7 +278,20 @@ post_start (void *cls, struct PostContext *ctx = cls; struct ANASTASIS_AUTHORIZATION_State *as; json_error_t error; - + enum GNUNET_DB_QueryStatus qs; + + /* If the user can show this challenge code, this + plugin is already happy (no additional + requirements), so mark this challenge as + already satisfied from the start. */ + qs = ctx->ac->db->mark_challenge_code_satisfied (ctx->ac->db->cls, + truth_uuid, + code); + if (qs <= 0) + { + GNUNET_break (0); + return NULL; + } as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State); as->trigger = trigger; as->trigger_cls = trigger_cls; diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c index b780c68..df398fd 100644 --- a/src/authorization/anastasis_authorization_plugin_sms.c +++ b/src/authorization/anastasis_authorization_plugin_sms.c @@ -24,6 +24,8 @@ #include #include #include "anastasis_util_lib.h" +#include +#include "anastasis_database_lib.h" /** @@ -247,7 +249,20 @@ sms_start (void *cls, { struct SMS_Context *ctx = cls; struct ANASTASIS_AUTHORIZATION_State *as; - + enum GNUNET_DB_QueryStatus qs; + + /* If the user can show this challenge code, this + plugin is already happy (no additional + requirements), so mark this challenge as + already satisfied from the start. */ + qs = ctx->ac->db->mark_challenge_code_satisfied (ctx->ac->db->cls, + truth_uuid, + code); + if (qs <= 0) + { + GNUNET_break (0); + return NULL; + } as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State); as->trigger = trigger; as->trigger_cls = trigger_cls; -- cgit v1.2.3