diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-01-31 12:52:04 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-01-31 12:52:04 +0100 |
commit | 9dded1aec4e5e62dce29ac86bc486112c7bff60d (patch) | |
tree | d3e386e04cc2ef58bf8bf4107edcf91cece2a66b /src/backenddb/plugin_merchantdb_postgres.c | |
parent | 10a3b45df075ec974f787783db9afeff09a54c88 (diff) | |
download | merchant-9dded1aec4e5e62dce29ac86bc486112c7bff60d.tar.gz merchant-9dded1aec4e5e62dce29ac86bc486112c7bff60d.tar.bz2 merchant-9dded1aec4e5e62dce29ac86bc486112c7bff60d.zip |
extend merchant backend DB to support storing authentication data for #6731
Diffstat (limited to 'src/backenddb/plugin_merchantdb_postgres.c')
-rw-r--r-- | src/backenddb/plugin_merchantdb_postgres.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c index babc47ca..4506c57e 100644 --- a/src/backenddb/plugin_merchantdb_postgres.c +++ b/src/backenddb/plugin_merchantdb_postgres.c @@ -484,11 +484,21 @@ lookup_instances_cb (void *cls, for (unsigned int i = 0; i < num_results; i++) { + bool no_auth; + bool no_salt; struct GNUNET_PQ_ResultSpec rs[] = { GNUNET_PQ_result_spec_uint64 ("merchant_serial", &lic->instance_serial), GNUNET_PQ_result_spec_auto_from_type ("merchant_pub", &lic->merchant_pub), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("auth_hash", + &lic->is.auth_hash), + &no_auth), + GNUNET_PQ_result_spec_allow_null ( + GNUNET_PQ_result_spec_auto_from_type ("auth_salt", + &lic->is.auth_salt), + &no_salt), GNUNET_PQ_result_spec_string ("merchant_id", &lic->is.id), GNUNET_PQ_result_spec_string ("merchant_name", @@ -514,6 +524,12 @@ lookup_instances_cb (void *cls, GNUNET_PQ_query_param_end }; + memset (&lic->is.auth_salt, + 0, + sizeof (lic->is.auth_salt)); + memset (&lic->is.auth_hash, + 0, + sizeof (lic->is.auth_hash)); if (GNUNET_OK != GNUNET_PQ_extract_result (result, rs, @@ -599,6 +615,8 @@ postgres_insert_instance (void *cls, struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (merchant_pub), + GNUNET_PQ_query_param_auto_from_type (&is->auth_hash), + GNUNET_PQ_query_param_auto_from_type (&is->auth_salt), GNUNET_PQ_query_param_string (is->id), GNUNET_PQ_query_param_string (is->name), TALER_PQ_query_param_json (is->address), @@ -736,6 +754,8 @@ postgres_update_instance (void *cls, GNUNET_PQ_query_param_relative_time ( &is->default_wire_transfer_delay), GNUNET_PQ_query_param_relative_time (&is->default_pay_delay), + GNUNET_PQ_query_param_auto_from_type (&is->auth_hash), + GNUNET_PQ_query_param_auto_from_type (&is->auth_salt), GNUNET_PQ_query_param_end }; @@ -6024,6 +6044,8 @@ postgres_connect (void *cls) "SELECT" " merchant_serial" ",merchant_pub" + ",auth_hash" + ",auth_salt" ",merchant_id" ",merchant_name" ",address" @@ -6041,6 +6063,8 @@ postgres_connect (void *cls) GNUNET_PQ_make_prepare ("insert_instance", "INSERT INTO merchant_instances" "(merchant_pub" + ",auth_hash" + ",auth_salt" ",merchant_id" ",merchant_name" ",address" @@ -6053,8 +6077,8 @@ postgres_connect (void *cls) ",default_wire_transfer_delay" ",default_pay_delay)" "VALUES" - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)", - 12), + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)", + 14), /* for postgres_insert_instance() */ GNUNET_PQ_make_prepare ("insert_keys", "INSERT INTO merchant_keys" @@ -6102,8 +6126,10 @@ postgres_connect (void *cls) ",default_wire_fee_amortization=$9" ",default_wire_transfer_delay=$10" ",default_pay_delay=$11" + ",auth_hash=$12" + ",auth_salt=$13" " WHERE merchant_id = $1", - 11), + 13), /* for postgres_inactivate_account() */ GNUNET_PQ_make_prepare ("inactivate_account", "UPDATE merchant_accounts SET" |