commit ff0ba9370ed5d4d0b7fa5491f273e0ab52c342e4 parent 4571665a1340be1cbdeda4988c2f94b5b617daec Author: Christian Grothoff <christian@grothoff.org> Date: Tue, 14 May 2024 10:19:17 +0200 store provider_name, instead of provider_section Diffstat:
27 files changed, 115 insertions(+), 263 deletions(-)
diff --git a/src/exchange/taler-exchange-httpd_kyc-proof.c b/src/exchange/taler-exchange-httpd_kyc-proof.c @@ -99,7 +99,7 @@ struct KycProofContext /** * Provider configuration section name of the logic we are running. */ - const char *provider_section; + const char *provider_name; /** * Row in the database for this legitimization operation. @@ -302,7 +302,7 @@ proof_cb ( kpc->kat = TEH_kyc_finished (&rc->async_scope_id, kpc->process_row, &kpc->h_payto, - kpc->provider_section, + kpc->provider_name, provider_user_id, provider_legitimization_id, expiration, @@ -356,7 +356,7 @@ proof_cb ( { if (! TEH_kyc_failed (kpc->process_row, &kpc->h_payto, - kpc->provider_section, + kpc->provider_name, provider_user_id, provider_legitimization_id)) { @@ -432,19 +432,19 @@ TEH_handler_kyc_proof ( const char *const args[1]) { struct KycProofContext *kpc = rc->rh_ctx; - const char *provider_section_or_logic = args[0]; + const char *provider_name_or_logic = args[0]; if (NULL == kpc) { /* first time */ - if (NULL == provider_section_or_logic) + if (NULL == provider_name_or_logic) { GNUNET_break_op (0); return respond_html_ec (rc, MHD_HTTP_NOT_FOUND, "kyc-proof-endpoint-unknown", TALER_EC_GENERIC_ENDPOINT_UNKNOWN, - "'/kyc-proof/$PROVIDER_SECTION?state=$H_PAYTO' required"); + "'/kyc-proof/$PROVIDER_NAME?state=$H_PAYTO' required"); } kpc = GNUNET_new (struct KycProofContext); kpc->rc = rc; @@ -454,37 +454,37 @@ TEH_handler_kyc_proof ( "state", &kpc->h_payto); if (GNUNET_OK != - TALER_KYCLOGIC_lookup_logic (provider_section_or_logic, + TALER_KYCLOGIC_lookup_logic (provider_name_or_logic, &kpc->logic, &kpc->pd, - &kpc->provider_section)) + &kpc->provider_name)) { GNUNET_break_op (0); return respond_html_ec (rc, MHD_HTTP_NOT_FOUND, "kyc-proof-target-unknown", TALER_EC_EXCHANGE_KYC_GENERIC_LOGIC_UNKNOWN, - provider_section_or_logic); + provider_name_or_logic); } - if (NULL != kpc->provider_section) + if (NULL != kpc->provider_name) { enum GNUNET_DB_QueryStatus qs; struct GNUNET_TIME_Absolute expiration; - if (0 != strcmp (provider_section_or_logic, - kpc->provider_section)) + if (0 != strcmp (provider_name_or_logic, + kpc->provider_name)) { GNUNET_break_op (0); return respond_html_ec (rc, MHD_HTTP_BAD_REQUEST, "kyc-proof-bad-request", TALER_EC_GENERIC_PARAMETER_MALFORMED, - "PROVIDER_SECTION"); + "PROVIDER_NAME"); } qs = TEH_plugin->lookup_kyc_process_by_account ( TEH_plugin->cls, - kpc->provider_section, + kpc->provider_name, &kpc->h_payto, &kpc->process_row, &expiration, @@ -504,7 +504,7 @@ TEH_handler_kyc_proof ( MHD_HTTP_NOT_FOUND, "kyc-proof-target-unknown", TALER_EC_EXCHANGE_KYC_PROOF_REQUEST_UNKNOWN, - kpc->provider_section); + kpc->provider_name); case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: break; } diff --git a/src/exchange/taler-exchange-httpd_kyc-webhook.c b/src/exchange/taler-exchange-httpd_kyc-webhook.c @@ -65,10 +65,10 @@ struct KycWebhookContext struct TALER_KYCLOGIC_Plugin *plugin; /** - * Section in the configuration of the configured - * KYC provider. + * Name of the KYC provider (suffix of the + * section name in the configuration). */ - const char *provider_section; + const char *provider_name; /** * Configuration for the specific action. @@ -177,7 +177,7 @@ kyc_aml_webhook_finished ( * @param cls closure * @param process_row legitimization process the webhook was about * @param account_id account the webhook was about - * @param provider_section name of the configuration section of the logic that was run + * @param provider_name name of the KYC provider that was run * @param provider_user_id set to user ID at the provider, or NULL if not supported or unknown * @param provider_legitimization_id set to legitimization process ID at the provider, or NULL if not supported or unknown * @param status KYC status @@ -191,7 +191,7 @@ webhook_finished_cb ( void *cls, uint64_t process_row, const struct TALER_PaytoHashP *account_id, - const char *provider_section, + const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, enum TALER_KYCLOGIC_KycStatus status, @@ -210,7 +210,7 @@ webhook_finished_cb ( &kwh->rc->async_scope_id, process_row, account_id, - provider_section, + provider_name, provider_user_id, provider_legitimization_id, expiration, @@ -242,7 +242,7 @@ webhook_finished_cb ( status); if (! TEH_kyc_failed (process_row, account_id, - provider_section, + provider_name, provider_user_id, provider_legitimization_id)) { @@ -330,7 +330,7 @@ handler_kyc_webhook_generic ( TALER_KYCLOGIC_lookup_logic (args[0], &kwh->plugin, &kwh->pd, - &kwh->provider_section)) ) + &kwh->provider_name)) ) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "KYC logic `%s' unknown (check KYC provider configuration)\n", @@ -343,7 +343,7 @@ handler_kyc_webhook_generic ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "KYC logic `%s' mapped to section %s\n", args[0], - kwh->provider_section); + kwh->provider_name); kwh->wh = kwh->plugin->webhook (kwh->plugin->cls, kwh->pd, TEH_plugin->kyc_provider_account_lookup, diff --git a/src/exchangedb/0005-legitimization_processes.sql b/src/exchangedb/0005-legitimization_processes.sql @@ -24,6 +24,7 @@ BEGIN PERFORM create_partitioned_table( 'ALTER TABLE %I' ' ADD COLUMN legitimization_measure_serial_id BIGINT' + ',RENAME COLUMN provider_section TO provider_name' ',ADD COLUMN measure_index INT4' ';' ,'legitimization_processes' diff --git a/src/exchangedb/exchange_do_insert_kyc_attributes.sql b/src/exchangedb/exchange_do_insert_kyc_attributes.sql @@ -18,6 +18,7 @@ CREATE OR REPLACE FUNCTION exchange_do_insert_kyc_attributes( IN in_process_row INT8, IN in_h_payto BYTEA, IN in_birthday INT4, + IN in_provider_name TEXT, IN in_provider_account_id TEXT, IN in_provider_legitimization_id TEXT, IN in_collection_time_ts INT8, @@ -54,7 +55,7 @@ UPDATE legitimization_processes ,finished=TRUE WHERE h_payto=in_h_payto AND legitimization_process_serial_id=in_process_row - AND provider_section=in_provider_section; + AND provider_name=in_provider_name; out_ok = FOUND; @@ -101,5 +102,5 @@ INSERT INTO kyc_alerts END $$; -COMMENT ON FUNCTION exchange_do_insert_kyc_attributes(INT8, BYTEA, INT4, TEXT, TEXT, INT8, INT8, INT8, BYTEA, BOOL, TEXT) +COMMENT ON FUNCTION exchange_do_insert_kyc_attributes(INT8, BYTEA, INT4, TEXT, TEXT, TEXT, INT8, INT8, INT8, BYTEA, BOOL, TEXT) IS 'Inserts new KYC attributes and updates the status of the legitimization process and the AML status for the account'; diff --git a/src/exchangedb/pg_get_pending_kyc_requirement_process.c b/src/exchangedb/pg_get_pending_kyc_requirement_process.c @@ -30,12 +30,12 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_pending_kyc_requirement_process ( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, char **redirect_url) { struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_end }; @@ -53,7 +53,7 @@ TEH_PG_get_pending_kyc_requirement_process ( "SELECT" " redirect_url" " FROM legitimization_processes" - " WHERE provider_section=$1" + " WHERE provider_name=$1" " AND h_payto=$2" " AND NOT finished" " ORDER BY start_time DESC" diff --git a/src/exchangedb/pg_get_pending_kyc_requirement_process.h b/src/exchangedb/pg_get_pending_kyc_requirement_process.h @@ -31,7 +31,7 @@ * * @param cls closure * @param h_payto account that must be KYC'ed - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param[out] redirect_url set to redirect URL for the process * @return database transaction status */ @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_get_pending_kyc_requirement_process ( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, char **redirect_url); #endif diff --git a/src/exchangedb/pg_insert_kyc_attributes.c b/src/exchangedb/pg_insert_kyc_attributes.c @@ -33,6 +33,7 @@ TEH_PG_insert_kyc_attributes ( const struct TALER_PaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, struct GNUNET_TIME_Absolute expiration_time, @@ -54,6 +55,7 @@ TEH_PG_insert_kyc_attributes ( GNUNET_PQ_query_param_uint64 (&process_row), GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_uint32 (&birthday), + GNUNET_PQ_query_param_string (provider_name), (NULL == provider_account_id) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_string (provider_account_id), @@ -85,7 +87,7 @@ TEH_PG_insert_kyc_attributes ( "SELECT " " out_ok" " FROM exchange_do_insert_kyc_attributes " - "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);"); + "($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);"); qs = GNUNET_PQ_eval_prepared_singleton_select (pg->conn, "insert_kyc_attributes", params, diff --git a/src/exchangedb/pg_insert_kyc_attributes.h b/src/exchangedb/pg_insert_kyc_attributes.h @@ -33,14 +33,11 @@ * @param cls closure * @param process_row KYC process row to update * @param h_payto account for which the attribute data is stored - * @param kyc_prox key for similarity search - * @param provider_section provider that must be checked - * @param num_checks how many checks do these attributes satisfy - * @param satisfied_checks array of checks satisfied by these attributes - * @param provider_account_id provider account ID - * @param provider_legitimization_id provider legitimization ID * @param birthday birthdate of user, in days after 1990, or 0 if unknown or definitively adult * @param collection_time when was the data collected + * @param provider_name name of the provider that provided the attributes + * @param provider_account_id provider account ID + * @param provider_legitimization_id provider legitimization ID * @param expiration_time when does the data expire * @param enc_attributes_size number of bytes in @a enc_attributes * @param enc_attributes encrypted attribute data @@ -54,6 +51,7 @@ TEH_PG_insert_kyc_attributes ( const struct TALER_PaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, struct GNUNET_TIME_Absolute expiration_time, diff --git a/src/exchangedb/pg_insert_kyc_failure.c b/src/exchangedb/pg_insert_kyc_failure.c @@ -32,7 +32,7 @@ TEH_PG_insert_kyc_failure ( void *cls, uint64_t process_row, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id) { @@ -40,7 +40,7 @@ TEH_PG_insert_kyc_failure ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&process_row), GNUNET_PQ_query_param_auto_from_type (h_payto), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), NULL != provider_account_id ? GNUNET_PQ_query_param_string (provider_account_id) : GNUNET_PQ_query_param_null (), @@ -60,7 +60,7 @@ TEH_PG_insert_kyc_failure ( " ,provider_legitimization_id=$5" " WHERE h_payto=$2" " AND legitimization_process_serial_id=$1" - " AND provider_section=$3;"); + " AND provider_name=$3;"); qs = GNUNET_PQ_eval_prepared_non_select (pg->conn, "insert_kyc_failure", params); diff --git a/src/exchangedb/pg_insert_kyc_failure.h b/src/exchangedb/pg_insert_kyc_failure.h @@ -32,7 +32,7 @@ * @param cls closure * @param process_row KYC process row to update * @param h_payto account for which the attribute data is stored - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID * @return database transaction status @@ -42,7 +42,7 @@ TEH_PG_insert_kyc_failure ( void *cls, uint64_t process_row, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id); diff --git a/src/exchangedb/pg_insert_kyc_requirement_for_account.c b/src/exchangedb/pg_insert_kyc_requirement_for_account.c @@ -28,7 +28,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_for_account ( void *cls, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, const struct TALER_ReservePublicKeyP *reserve_pub, uint64_t *requirement_row) @@ -39,7 +39,7 @@ TEH_PG_insert_kyc_requirement_for_account ( (NULL == reserve_pub) ? GNUNET_PQ_query_param_null () : GNUNET_PQ_query_param_auto_from_type (reserve_pub), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { diff --git a/src/exchangedb/pg_insert_kyc_requirement_for_account.h b/src/exchangedb/pg_insert_kyc_requirement_for_account.h @@ -30,7 +30,7 @@ * Insert KYC requirement for @a h_payto account into table. * * @param cls closure - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param h_payto account that must be KYC'ed * @param reserve_pub if the account is a reserve, its public key. Maybe NULL * @param[out] requirement_row set to legitimization requirement row for this check @@ -39,7 +39,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_for_account ( void *cls, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, const struct TALER_ReservePublicKeyP *reserve_pub, uint64_t *requirement_row); diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.c b/src/exchangedb/pg_insert_kyc_requirement_process.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_process ( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, uint64_t *process_row) @@ -41,7 +41,7 @@ TEH_PG_insert_kyc_requirement_process ( struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), GNUNET_PQ_query_param_absolute_time (&now), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), (NULL != provider_account_id) ? GNUNET_PQ_query_param_string (provider_account_id) : GNUNET_PQ_query_param_null (), @@ -61,7 +61,7 @@ TEH_PG_insert_kyc_requirement_process ( "INSERT INTO legitimization_processes" " (h_payto" " ,start_time" - " ,provider_section" + " ,provider_name" " ,provider_user_id" " ,provider_legitimization_id" " ) VALUES " diff --git a/src/exchangedb/pg_insert_kyc_requirement_process.h b/src/exchangedb/pg_insert_kyc_requirement_process.h @@ -31,7 +31,7 @@ * * @param cls closure * @param h_payto account that must be KYC'ed - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID * @param[out] process_row row the process is stored under @@ -41,7 +41,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_insert_kyc_requirement_process ( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, uint64_t *process_row); diff --git a/src/exchangedb/pg_insert_records_by_table.c b/src/exchangedb/pg_insert_records_by_table.c @@ -307,7 +307,7 @@ irbt_cb_table_legitimization_processes ( GNUNET_PQ_query_param_uint32 ( &td->details.legitimization_processes.measure_index), GNUNET_PQ_query_param_string ( - td->details.legitimization_processes.provider_section), + td->details.legitimization_processes.provider_name), GNUNET_PQ_query_param_string ( td->details.legitimization_processes.provider_user_id), GNUNET_PQ_query_param_string ( @@ -326,7 +326,7 @@ irbt_cb_table_legitimization_processes ( ",expiration_time" ",legitimization_measure_serial_id" ",measure_index" - ",provider_section" + ",provider_name" ",provider_user_id" ",provider_legitimization_id" ",redirect_url" diff --git a/src/exchangedb/pg_iterate_kyc_reference.c b/src/exchangedb/pg_iterate_kyc_reference.c @@ -65,12 +65,12 @@ iterate_kyc_reference_cb (void *cls, for (unsigned int i = 0; i<num_results; i++) { - char *kyc_provider_section_name; + char *kyc_provider_name_name; char *provider_user_id; char *legitimization_id; struct GNUNET_PQ_ResultSpec rs[] = { - GNUNET_PQ_result_spec_string ("provider_section", - &kyc_provider_section_name), + GNUNET_PQ_result_spec_string ("provider_name", + &kyc_provider_name_name), GNUNET_PQ_result_spec_string ("provider_user_id", &provider_user_id), GNUNET_PQ_result_spec_string ("provider_legitimization_id", @@ -87,7 +87,7 @@ iterate_kyc_reference_cb (void *cls, return; } ic->cb (ic->cb_cls, - kyc_provider_section_name, + kyc_provider_name_name, provider_user_id, legitimization_id); GNUNET_PQ_cleanup_result (rs); @@ -116,7 +116,7 @@ TEH_PG_iterate_kyc_reference ( PREPARE (pg, "iterate_kyc_reference", "SELECT " - " provider_section" + " provider_name" ",provider_user_id" ",provider_legitimization_id" " FROM legitimization_processes" diff --git a/src/exchangedb/pg_kyc_provider_account_lookup.c b/src/exchangedb/pg_kyc_provider_account_lookup.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_kyc_provider_account_lookup ( void *cls, - const char *provider_section, + const char *provider_name, const char *provider_legitimization_id, struct TALER_PaytoHashP *h_payto, uint64_t *process_row) @@ -37,7 +37,7 @@ TEH_PG_kyc_provider_account_lookup ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_string (provider_legitimization_id), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -55,7 +55,7 @@ TEH_PG_kyc_provider_account_lookup ( ",legitimization_process_serial_id" " FROM legitimization_processes" " WHERE provider_legitimization_id=$1" - " AND provider_section=$2;"); + " AND provider_name=$2;"); return GNUNET_PQ_eval_prepared_singleton_select ( pg->conn, "get_wire_target_by_legitimization_id", diff --git a/src/exchangedb/pg_kyc_provider_account_lookup.h b/src/exchangedb/pg_kyc_provider_account_lookup.h @@ -31,7 +31,7 @@ * @a h_payto by @a provider_legitimization_id. * * @param cls closure - * @param provider_section + * @param provider_name * @param provider_legitimization_id legi to look up * @param[out] h_payto where to write the result * @param[out] process_row where to write the row of the entry @@ -40,7 +40,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_kyc_provider_account_lookup ( void *cls, - const char *provider_section, + const char *provider_name, const char *provider_legitimization_id, struct TALER_PaytoHashP *h_payto, uint64_t *process_row); diff --git a/src/exchangedb/pg_lookup_kyc_process_by_account.c b/src/exchangedb/pg_lookup_kyc_process_by_account.c @@ -29,7 +29,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_process_by_account ( void *cls, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, @@ -39,7 +39,7 @@ TEH_PG_lookup_kyc_process_by_account ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_auto_from_type (h_payto), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), GNUNET_PQ_query_param_end }; struct GNUNET_PQ_ResultSpec rs[] = { @@ -69,7 +69,7 @@ TEH_PG_lookup_kyc_process_by_account ( ",provider_legitimization_id" " FROM legitimization_processes" " WHERE h_payto=$1" - " AND provider_section=$2" + " AND provider_name=$2" " AND NOT finished" /* Note: there *should* only be one unfinished match, so this is just to be safe(r): */ diff --git a/src/exchangedb/pg_lookup_kyc_process_by_account.h b/src/exchangedb/pg_lookup_kyc_process_by_account.h @@ -30,7 +30,7 @@ * Lookup KYC provider meta data. * * @param cls closure - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param h_payto account that must be KYC'ed * @param[out] process_row row with the legitimization data * @param[out] expiration how long is this KYC check set to be valid (in the past if invalid) @@ -41,7 +41,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_lookup_kyc_process_by_account ( void *cls, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, diff --git a/src/exchangedb/pg_lookup_records_by_table.c b/src/exchangedb/pg_lookup_records_by_table.c @@ -2788,8 +2788,8 @@ lrbt_cb_table_legitimization_processes (void *cls, "measure_index", &td.details.legitimization_processes.measure_index), GNUNET_PQ_result_spec_string ( - "provider_section", - &td.details.legitimization_processes.provider_section), + "provider_name", + &td.details.legitimization_processes.provider_name), GNUNET_PQ_result_spec_string ( "provider_user_id", &td.details.legitimization_processes.provider_user_id), @@ -3660,7 +3660,7 @@ TEH_PG_lookup_records_by_table (void *cls, ",expiration_time" ",legitimization_measure_serial_id" ",measure_index" - ",provider_section" + ",provider_name" ",provider_user_id" ",provider_legitimization_id" ",redirect_url" diff --git a/src/exchangedb/pg_update_kyc_process_by_row.c b/src/exchangedb/pg_update_kyc_process_by_row.c @@ -30,7 +30,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_update_kyc_process_by_row ( void *cls, uint64_t process_row, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, @@ -40,7 +40,7 @@ TEH_PG_update_kyc_process_by_row ( struct PostgresClosure *pg = cls; struct GNUNET_PQ_QueryParam params[] = { GNUNET_PQ_query_param_uint64 (&process_row), - GNUNET_PQ_query_param_string (provider_section), + GNUNET_PQ_query_param_string (provider_name), GNUNET_PQ_query_param_auto_from_type (h_payto), (NULL != provider_account_id) ? GNUNET_PQ_query_param_string (provider_account_id) @@ -59,7 +59,7 @@ TEH_PG_update_kyc_process_by_row ( GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Updating KYC data for %llu (%s)\n", (unsigned long long) process_row, - provider_section); + provider_name); PREPARE (pg, "update_legitimization_process", "UPDATE legitimization_processes" @@ -70,7 +70,7 @@ TEH_PG_update_kyc_process_by_row ( " WHERE" " h_payto=$3" " AND legitimization_process_serial_id=$1" - " AND provider_section=$2;"); + " AND provider_name=$2;"); qs = GNUNET_PQ_eval_prepared_non_select ( pg->conn, "update_legitimization_process", diff --git a/src/exchangedb/pg_update_kyc_process_by_row.h b/src/exchangedb/pg_update_kyc_process_by_row.h @@ -31,7 +31,7 @@ * * @param cls closure * @param process_row row to select by - * @param provider_section provider that must be checked (technically redundant) + * @param provider_name provider that must be checked (technically redundant) * @param h_payto account that must be KYC'ed (helps access by shard, otherwise also redundant) * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID @@ -43,7 +43,7 @@ enum GNUNET_DB_QueryStatus TEH_PG_update_kyc_process_by_row ( void *cls, uint64_t process_row, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, diff --git a/src/include/taler_exchangedb_plugin.h b/src/include/taler_exchangedb_plugin.h @@ -411,7 +411,7 @@ struct TALER_EXCHANGEDB_TableData struct GNUNET_TIME_Timestamp expiration_time; uint64_t legitimization_measure_serial_id; uint32_t measure_index; - char *provider_section; + char *provider_name; char *provider_user_id; char *provider_legitimization_id; char *redirect_url; @@ -1117,7 +1117,7 @@ typedef void * (and that have not yet expired). * * @param cls closure - * @param kyc_provider_section_name configuration section + * @param kyc_provider_name name of the provider * of the respective KYC process * @param provider_user_id UID at a provider (can be NULL) * @param legi_id legitimization process ID (can be NULL) @@ -1125,7 +1125,7 @@ typedef void typedef void (*TALER_EXCHANGEDB_LegitimizationProcessCallback)( void *cls, - const char *kyc_provider_section_name, + const char *kyc_provider_name, const char *provider_user_id, const char *legi_id); @@ -2638,7 +2638,7 @@ typedef void * * @param cls closure * @param h_payto account for which the attribute data is stored - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param collection_time when was the data collected * @param expiration_time when does the data expire * @param enc_attributes_size number of bytes in @a enc_attributes @@ -2648,7 +2648,7 @@ typedef void (*TALER_EXCHANGEDB_AttributeCallback)( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, struct GNUNET_TIME_Timestamp collection_time, struct GNUNET_TIME_Timestamp expiration_time, size_t enc_attributes_size, @@ -6742,7 +6742,7 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls closure * @param h_payto account that must be KYC'ed - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID * @param[out] process_row row the process is stored under @@ -6752,7 +6752,7 @@ struct TALER_EXCHANGEDB_Plugin (*insert_kyc_requirement_process)( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, uint64_t *process_row); @@ -6763,7 +6763,7 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls closure * @param h_payto account that must be KYC'ed - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param[out] redirect_url set to redirect URL for the process * @return database transaction status */ @@ -6771,7 +6771,7 @@ struct TALER_EXCHANGEDB_Plugin (*get_pending_kyc_requirement_process)( void *cls, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, char **redirect_url); @@ -6781,7 +6781,7 @@ struct TALER_EXCHANGEDB_Plugin * * @param cls closure * @param process_row row to select by - * @param provider_section provider that must be checked (technically redundant) + * @param provider_name provider that must be checked (technically redundant) * @param h_payto account that must be KYC'ed (helps access by shard, otherwise also redundant) * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID @@ -6793,7 +6793,7 @@ struct TALER_EXCHANGEDB_Plugin (*update_kyc_process_by_row)( void *cls, uint64_t process_row, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, const char *provider_account_id, const char *provider_legitimization_id, @@ -6825,7 +6825,7 @@ struct TALER_EXCHANGEDB_Plugin * Lookup KYC process meta data. * * @param cls closure - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param h_payto account that must be KYC'ed * @param[out] process_row set to row with the legitimization data * @param[out] expiration how long is this KYC check set to be valid (in the past if invalid) @@ -6836,7 +6836,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*lookup_kyc_process_by_account)( void *cls, - const char *provider_section, + const char *provider_name, const struct TALER_PaytoHashP *h_payto, uint64_t *process_row, struct GNUNET_TIME_Absolute *expiration, @@ -6849,7 +6849,7 @@ struct TALER_EXCHANGEDB_Plugin * @a h_payto by @a provider_legitimization_id. * * @param cls closure - * @param provider_section + * @param provider_name * @param provider_legitimization_id legi to look up * @param[out] h_payto where to write the result * @param[out] process_row identifies the legitimization process on our end @@ -6858,7 +6858,7 @@ struct TALER_EXCHANGEDB_Plugin enum GNUNET_DB_QueryStatus (*kyc_provider_account_lookup)( void *cls, - const char *provider_section, + const char *provider_name, const char *provider_legitimization_id, struct TALER_PaytoHashP *h_payto, uint64_t *process_row); @@ -6965,6 +6965,7 @@ struct TALER_EXCHANGEDB_Plugin * @param cls closure * @param process_row KYC process row to update * @param h_payto account for which the attribute data is stored + * @param provider_name name of the provider that collected the data * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID * @param birthday birthdate of user, in days after 1990, or 0 if unknown or definitively adult @@ -6982,6 +6983,7 @@ struct TALER_EXCHANGEDB_Plugin const struct TALER_PaytoHashP *h_payto, uint32_t birthday, struct GNUNET_TIME_Timestamp collection_time, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id, struct GNUNET_TIME_Absolute expiration_time, @@ -7186,7 +7188,7 @@ struct TALER_EXCHANGEDB_Plugin * @param cls closure * @param process_row KYC process row to update * @param h_payto account for which the attribute data is stored - * @param provider_section provider that must be checked + * @param provider_name provider that must be checked * @param provider_account_id provider account ID * @param provider_legitimization_id provider legitimization ID * @return database transaction status @@ -7196,7 +7198,7 @@ struct TALER_EXCHANGEDB_Plugin void *cls, uint64_t process_row, const struct TALER_PaytoHashP *h_payto, - const char *provider_section, + const char *provider_name, const char *provider_account_id, const char *provider_legitimization_id); diff --git a/src/include/taler_kyclogic_lib.h b/src/include/taler_kyclogic_lib.h @@ -289,7 +289,7 @@ TALER_KYCLOGIC_requirements_to_logic ( /** * Obtain the provider logic for a given @a name. * - * @param name name of the logic or provider section + * @param name name of the logic or provider * @param[out] plugin set to the KYC logic API * @param[out] pd set to the specific operation context * @param[out] configuration_section set to the name of the KYC logic configuration section diff --git a/src/include/taler_kyclogic_plugin.h b/src/include/taler_kyclogic_plugin.h @@ -188,7 +188,7 @@ typedef void * @param cls closure * @param process_row legitimization process the webhook was about * @param account_id account the webhook was about - * @param provider_section name of the configuration section of the logic that was run + * @param provider_name name of the provider that was run * @param provider_user_id set to user ID at the provider, or NULL if not supported or unknown * @param provider_legitimization_id set to legitimization process ID at the provider, or NULL if not supported or unknown * @param status KYC status @@ -202,7 +202,7 @@ typedef void void *cls, uint64_t process_row, const struct TALER_PaytoHashP *account_id, - const char *provider_section, + const char *provider_name, const char *provider_user_id, const char *provider_legitimization_id, enum TALER_KYCLOGIC_KycStatus status, @@ -218,7 +218,7 @@ typedef void * of the exchange's database plugin. * * @param cls closure - * @param provider_section + * @param provider_name * @param provider_legitimization_id legi to look up * @param[out] h_payto where to write the result * @param[out] process_row where to write the row of the entry @@ -227,7 +227,7 @@ typedef void typedef enum GNUNET_DB_QueryStatus (*TALER_KYCLOGIC_ProviderLookupCallback)( void *cls, - const char *provider_section, + const char *provider_name, const char *provider_legitimization_id, struct TALER_PaytoHashP *h_payto, uint64_t *process_row); diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c @@ -40,11 +40,16 @@ struct TALER_KYCLOGIC_KycProvider struct TALER_Amount cost; /** - * Name of the provider (configuration section name). + * Name of the provider. */ char *provider_name; /** + * Name of the configuration section of the provider. + */ + char *provider_section_name; + + /** * Name of a program to run to convert output of the * plugin into the desired set of attributes. */ @@ -781,6 +786,7 @@ add_provider (const struct GNUNET_CONFIGURATION_Handle *cfg, kp->cost = cost; kp->provider_name = GNUNET_strdup (§ion[strlen ("kyc-provider-")]); + kp->provider_section_name = GNUNET_strdup (section); kp->converter_name = converter; kp->logic = lp; kp->pd = pd; @@ -1456,6 +1462,7 @@ TALER_KYCLOGIC_kyc_done (void) kp->logic->unload_configuration (kp->pd); GNUNET_free (kp->provider_name); + GNUNET_free (kp->provider_section_name); GNUNET_free (kp->converter_name); GNUNET_free (kp); } @@ -1694,20 +1701,19 @@ TALER_KYCLOGIC_lookup_logic ( const char *name, struct TALER_KYCLOGIC_Plugin **plugin, struct TALER_KYCLOGIC_ProviderDetails **pd, - const char **provider_section) + const char **provider_name) { -#if FIXME for (unsigned int i = 0; i<num_kyc_providers; i++) { struct TALER_KYCLOGIC_KycProvider *kp = kyc_providers[i]; if (0 != strcasecmp (name, - kp->provider_section_name)) + kp->provider_name)) continue; *plugin = kp->logic; *pd = kp->pd; - *provider_section = kp->provider_section_name; + *provider_section = kp->provider_name; return GNUNET_OK; } for (unsigned int i = 0; i<num_kyc_logics; i++) @@ -1726,9 +1732,6 @@ TALER_KYCLOGIC_lookup_logic ( GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Provider `%s' unknown\n", name); -#else - GNUNET_break (0); -#endif return GNUNET_SYSERR; } @@ -1885,161 +1888,6 @@ TALER_KYCLOGIC_kyc_test_required ( /* end of kyclogic_api.c */ #if 0 -// FIXME from here... - - -/** - * Closure for the #eval_trigger(). - */ -struct ThresholdTestContext -{ - /** - * Total amount so far. - */ - struct TALER_Amount total; - - /** - * Trigger event to evaluate triggers of. - */ - enum TALER_KYCLOGIC_KycTriggerEvent event; - - /** - * Offset in the triggers array where we need to start - * checking for triggers. All trigges below this - * offset were already hit. - */ - unsigned int start; - - /** - * Array of checks needed so far. - */ - struct TALER_KYCLOGIC_KycCheck **needed; - - /** - * Pointer to number of entries used in @a needed. - */ - unsigned int *needed_cnt; - - /** - * Has @e total been initialized yet? - */ - bool have_total; -}; - - -/** - * Function called on each @a amount that was found to - * be relevant for a KYC check. - * - * @param cls closure to allow the KYC module to - * total up amounts and evaluate rules - * @param amount encountered transaction amount - * @param date when was the amount encountered - * @return #GNUNET_OK to continue to iterate, - * #GNUNET_NO to abort iteration - * #GNUNET_SYSERR on internal error (also abort itaration) - */ -static enum GNUNET_GenericReturnValue -eval_trigger (void *cls, - const struct TALER_Amount *amount, - struct GNUNET_TIME_Absolute date) -{ - struct ThresholdTestContext *ttc = cls; - struct GNUNET_TIME_Relative duration; - bool bump = true; - - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check with new amount %s\n", - TALER_amount2s (amount)); - duration = GNUNET_TIME_absolute_get_duration (date); - if (ttc->have_total) - { - if (0 > - TALER_amount_add (&ttc->total, - &ttc->total, - amount)) - { - GNUNET_break (0); - return GNUNET_SYSERR; - } - } - else - { - ttc->total = *amount; - ttc->have_total = true; - } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check: new total is %s\n", - TALER_amount2s (&ttc->total)); - for (unsigned int i = ttc->start; i<num_kyc_triggers; i++) - { - const struct TALER_KYCLOGIC_KycTrigger *kt = kyc_triggers[i]; - - if (ttc->event != kt->trigger) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check #%u: trigger type does not match\n", - i); - continue; - } - duration = GNUNET_TIME_relative_max (duration, - kt->timeframe); - if (GNUNET_TIME_relative_cmp (kt->timeframe, - >, - duration)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check #%u: amount is beyond time limit\n", - i); - if (bump) - ttc->start = i; - return GNUNET_OK; - } - if (-1 == - TALER_amount_cmp (&ttc->total, - &kt->threshold)) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check #%u: amount is below threshold\n", - i); - if (bump) - ttc->start = i; - bump = false; - continue; /* amount too low to trigger */ - } - /* add check to list of required checks, unless - already present... */ - for (unsigned int j = 0; j<kt->num_checks; j++) - { - struct TALER_KYCLOGIC_KycCheck *rc = kt->required_checks[j]; - bool found = false; - - for (unsigned int k = 0; k<*ttc->needed_cnt; k++) - if (ttc->needed[k] == rc) - { - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC rule #%u already listed\n", - j); - found = true; - break; - } - if (! found) - { - ttc->needed[*ttc->needed_cnt] = rc; - (*ttc->needed_cnt)++; - } - } - GNUNET_log (GNUNET_ERROR_TYPE_INFO, - "KYC check #%u (%s) is applicable, %u checks needed so far\n", - i, - ttc->needed[(*ttc->needed_cnt) - 1]->name, - *ttc->needed_cnt); - } - if (bump) - return GNUNET_NO; /* we hit all possible triggers! */ - return GNUNET_OK; -} - void TALER_KYCLOGIC_lookup_checks (const char *section_name,