summaryrefslogtreecommitdiff
path: root/src/stasis/plugin_anastasis_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-16 11:01:38 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-16 11:01:38 +0200
commitc1c40eaa24926273a6aa688e92e99d832aa1501e (patch)
treed5d01686cd125e70d1702ac5bbc2660c71d90760 /src/stasis/plugin_anastasis_postgres.c
parent3b90e437e26013f5570d6c216b832c7bcd740712 (diff)
downloadanastasis-c1c40eaa24926273a6aa688e92e99d832aa1501e.tar.gz
anastasis-c1c40eaa24926273a6aa688e92e99d832aa1501e.tar.bz2
anastasis-c1c40eaa24926273a6aa688e92e99d832aa1501e.zip
-preparations for sepa auth plugin
Diffstat (limited to 'src/stasis/plugin_anastasis_postgres.c')
-rw-r--r--src/stasis/plugin_anastasis_postgres.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/stasis/plugin_anastasis_postgres.c b/src/stasis/plugin_anastasis_postgres.c
index 9d206c7..325bae8 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -1759,6 +1759,11 @@ struct CheckValidityContext
bool valid;
/**
+ * Set to true if a code matching @e hashed_code was set to 'satisfied' by the plugin.
+ */
+ bool satisfied;
+
+ /**
* Set to true if we had a database failure.
*/
bool db_failure;
@@ -1786,9 +1791,12 @@ check_valid_code (void *cls,
for (unsigned int i = 0; i < num_results; i++)
{
uint64_t server_code;
+ uint8_t sat;
struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_uint64 ("code",
&server_code),
+ GNUNET_PQ_result_spec_auto_from_type ("satisfied",
+ &sat),
GNUNET_PQ_result_spec_end
};
@@ -1811,6 +1819,7 @@ check_valid_code (void *cls,
cvc->hashed_code))
{
cvc->valid = true;
+ cvc->satisfied = (0 != sat);
}
else
{
@@ -1844,13 +1853,15 @@ check_valid_code (void *cls,
* @param cls closure
* @param truth_uuid identification of the challenge which the code corresponds to
* @param hashed_code code which the user provided and wants to verify
+ * @param[out] satisfied set to true if the challenge is set to satisfied
* @return code validity status
*/
enum ANASTASIS_DB_CodeStatus
postgres_verify_challenge_code (
void *cls,
const struct ANASTASIS_CRYPTO_TruthUUIDP *truth_uuid,
- const struct GNUNET_HashCode *hashed_code)
+ const struct GNUNET_HashCode *hashed_code,
+ bool *satisfied)
{
struct PostgresClosure *pg = cls;
struct CheckValidityContext cvc = {
@@ -1866,6 +1877,7 @@ postgres_verify_challenge_code (
};
enum GNUNET_DB_QueryStatus qs;
+ *satisfied = false;
check_connection (pg);
GNUNET_TIME_round_abs (&now);
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
@@ -1877,7 +1889,10 @@ postgres_verify_challenge_code (
(cvc.db_failure) )
return ANASTASIS_DB_CODE_STATUS_HARD_ERROR;
if (cvc.valid)
+ {
+ *satisfied = cvc.satisfied;
return ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED;
+ }
if (0 == qs)
return ANASTASIS_DB_CODE_STATUS_NO_RESULTS;
return ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH;
@@ -2523,6 +2538,7 @@ libanastasis_plugin_db_postgres_init (void *cls)
GNUNET_PQ_make_prepare ("challengecode_select",
"SELECT "
" code"
+ ",satisfied"
" FROM anastasis_challengecode"
" WHERE truth_uuid=$1"
" AND expiration_date > $2"