(preliminary) work on kycaid plugin

This commit is contained in:
Christian Grothoff 2022-08-15 13:48:13 +02:00
parent 39640c3339
commit 96265412cd
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
10 changed files with 1488 additions and 34 deletions

@ -1 +1 @@
Subproject commit 88f1513c159014a1cbc6d0745568770538d2b0a9 Subproject commit 1a8af54b491e8300287eb7afb08ba22b91107f9a

View File

@ -4563,6 +4563,7 @@ prepare_statements (struct PostgresClosure *pg)
"get_wire_target_by_legitimization_id", "get_wire_target_by_legitimization_id",
"SELECT " "SELECT "
" h_payto" " h_payto"
",legitimization_serial_id"
" FROM legitimizations" " FROM legitimizations"
" WHERE provider_legitimization_id=$1" " WHERE provider_legitimization_id=$1"
" AND provider_section=$2;", " AND provider_section=$2;",
@ -16680,6 +16681,7 @@ postgres_lookup_kyc_requirement_by_account (
* @param provider_section * @param provider_section
* @param provider_legitimization_id legi to look up * @param provider_legitimization_id legi to look up
* @param[out] h_payto where to write the result * @param[out] h_payto where to write the result
* @param[out] legi_row where to write the row of the entry
* @return database transaction status * @return database transaction status
*/ */
static enum GNUNET_DB_QueryStatus static enum GNUNET_DB_QueryStatus
@ -16687,7 +16689,8 @@ postgres_kyc_provider_account_lookup (
void *cls, void *cls,
const char *provider_section, const char *provider_section,
const char *provider_legitimization_id, const char *provider_legitimization_id,
struct TALER_PaytoHashP *h_payto) struct TALER_PaytoHashP *h_payto,
uint64_t *legi_row)
{ {
struct PostgresClosure *pg = cls; struct PostgresClosure *pg = cls;
struct GNUNET_PQ_QueryParam params[] = { struct GNUNET_PQ_QueryParam params[] = {
@ -16698,6 +16701,8 @@ postgres_kyc_provider_account_lookup (
struct GNUNET_PQ_ResultSpec rs[] = { struct GNUNET_PQ_ResultSpec rs[] = {
GNUNET_PQ_result_spec_auto_from_type ("h_payto", GNUNET_PQ_result_spec_auto_from_type ("h_payto",
h_payto), h_payto),
GNUNET_PQ_result_spec_uint64 ("legitimization_serial_id",
legi_row),
GNUNET_PQ_result_spec_end GNUNET_PQ_result_spec_end
}; };

View File

@ -5675,6 +5675,7 @@ struct TALER_EXCHANGEDB_Plugin
* @param provider_section * @param provider_section
* @param provider_legitimization_id legi to look up * @param provider_legitimization_id legi to look up
* @param[out] h_payto where to write the result * @param[out] h_payto where to write the result
* @param[out] legi_row where to write the row of the entry
* @return database transaction status * @return database transaction status
*/ */
enum GNUNET_DB_QueryStatus enum GNUNET_DB_QueryStatus
@ -5682,7 +5683,8 @@ struct TALER_EXCHANGEDB_Plugin
void *cls, void *cls,
const char *provider_section, const char *provider_section,
const char *provider_legitimization_id, const char *provider_legitimization_id,
struct TALER_PaytoHashP *h_payto); struct TALER_PaytoHashP *h_payto,
uint64_t *legi_row);
/** /**

View File

@ -210,6 +210,7 @@ typedef void
* @param provider_section * @param provider_section
* @param provider_legitimization_id legi to look up * @param provider_legitimization_id legi to look up
* @param[out] h_payto where to write the result * @param[out] h_payto where to write the result
* @param[out] legi_row where to write the row of the entry
* @return database transaction status * @return database transaction status
*/ */
typedef enum GNUNET_DB_QueryStatus typedef enum GNUNET_DB_QueryStatus
@ -217,7 +218,8 @@ typedef enum GNUNET_DB_QueryStatus
void *cls, void *cls,
const char *provider_section, const char *provider_section,
const char *provider_legitimization_id, const char *provider_legitimization_id,
struct TALER_PaytoHashP *h_payto); struct TALER_PaytoHashP *h_payto,
uint64_t *legi_row);
/** /**

View File

@ -10,6 +10,7 @@ pkgcfgdir = $(prefix)/share/taler/config.d/
pkgcfg_DATA = \ pkgcfg_DATA = \
kyclogic.conf \ kyclogic.conf \
kyclogic-kycaid.conf \
kyclogic-oauth2.conf kyclogic-oauth2.conf
EXTRA_DIST = \ EXTRA_DIST = \
@ -53,6 +54,7 @@ taler_exchange_kyc_tester_LDADD = \
plugindir = $(libdir)/taler plugindir = $(libdir)/taler
plugin_LTLIBRARIES = \ plugin_LTLIBRARIES = \
libtaler_plugin_kyclogic_kycaid.la \
libtaler_plugin_kyclogic_oauth2.la \ libtaler_plugin_kyclogic_oauth2.la \
libtaler_plugin_kyclogic_template.la libtaler_plugin_kyclogic_template.la
@ -73,4 +75,18 @@ libtaler_plugin_kyclogic_oauth2_la_LDFLAGS = \
-ljansson \ -ljansson \
$(XLIB) $(XLIB)
libtaler_plugin_kyclogic_kycaid_la_SOURCES = \
plugin_kyclogic_kycaid.c
libtaler_plugin_kyclogic_kycaid_la_LIBADD = \
$(LTLIBINTL)
libtaler_plugin_kyclogic_kycaid_la_LDFLAGS = \
$(TALER_PLUGIN_LDFLAGS) \
$(top_builddir)/src/json/libtalerjson.la \
$(top_builddir)/src/curl/libtalercurl.la \
$(top_builddir)/src/util/libtalerutil.la \
-lgnunetutil \
-ljansson \
-lcurl \
$(XLIB)
AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH; AM_TESTS_ENVIRONMENT=export TALER_PREFIX=$${TALER_PREFIX:-@libdir@};export PATH=$${TALER_PREFIX:-@prefix@}/bin:$$PATH;

View File

@ -0,0 +1,22 @@
# This file is in the public domain.
# Example kycaid provider configuration.
[kyc-provider-example-kycaid]
COST = 42
LOGIC = kycaid
USER_TYPE = INDIVIDUAL
PROVIDED_CHECKS = EXAMPLE_DO_NOT_USE
# How long is the KYC check valid?
KYC_KYCAID_VALIDITY = forever
# Authentication token to use.
KYC_KYCAID_AUTH_TOKEN = XXX
# Form to use.
KYC_KYCAID_FORM_ID = XXX
# Authentication token to use.
KYC_KYCAID_POST_URL = https://example.com/

View File

@ -288,10 +288,12 @@ load_logic (const struct GNUNET_CONFIGURATION_Handle *cfg,
} }
plugin = GNUNET_PLUGIN_load (lib_name, plugin = GNUNET_PLUGIN_load (lib_name,
(void *) cfg); (void *) cfg);
if (NULL != plugin) if (NULL == plugin)
plugin->library_name = lib_name; {
else
GNUNET_free (lib_name); GNUNET_free (lib_name);
return NULL;
}
plugin->library_name = lib_name;
GNUNET_array_append (kyc_logics, GNUNET_array_append (kyc_logics,
num_kyc_logics, num_kyc_logics,
plugin); plugin);

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,11 @@ struct TALER_KYCLOGIC_ProviderDetails
*/ */
struct PluginState *ps; struct PluginState *ps;
/**
* Configuration section that configured us.
*/
char *section;
}; };
@ -130,6 +135,11 @@ struct TALER_KYCLOGIC_ProofHandle
* Closure for @e cb. * Closure for @e cb.
*/ */
void *cb_cls; void *cb_cls;
/**
* Connection we are handling.
*/
struct MHD_Connection *connection;
}; };
@ -164,9 +174,25 @@ struct TALER_KYCLOGIC_WebhookHandle
*/ */
const struct TALER_KYCLOGIC_ProviderDetails *pd; const struct TALER_KYCLOGIC_ProviderDetails *pd;
/**
* Connection we are handling.
*/
struct MHD_Connection *connection;
}; };
/**
* Release configuration resources previously loaded
*
* @param[in] pd configuration to release
*/
static void
template_unload_configuration (struct TALER_KYCLOGIC_ProviderDetails *pd)
{
GNUNET_free (pd);
}
/** /**
* Load the configuration of the KYC provider. * Load the configuration of the KYC provider.
* *
@ -183,20 +209,22 @@ template_load_configuration (void *cls,
pd = GNUNET_new (struct TALER_KYCLOGIC_ProviderDetails); pd = GNUNET_new (struct TALER_KYCLOGIC_ProviderDetails);
pd->ps = ps; pd->ps = ps;
pd->section = GNUNET_strdup (provider_section_name);
GNUNET_break (0); // FIXME: parse config here! GNUNET_break (0); // FIXME: parse config here!
return pd; return pd;
} }
/** /**
* Release configuration resources previously loaded * Cancel KYC check initiation.
* *
* @param[in] pd configuration to release * @param[in] ih handle of operation to cancel
*/ */
static void static void
template_unload_configuration (struct TALER_KYCLOGIC_ProviderDetails *pd) template_initiate_cancel (struct TALER_KYCLOGIC_InitiateHandle *ih)
{ {
GNUNET_free (pd); GNUNET_break (0); // FIXME: add cancel logic here
GNUNET_free (ih);
} }
@ -233,15 +261,15 @@ template_initiate (void *cls,
/** /**
* Cancel KYC check initiation. * Cancel KYC proof.
* *
* @param[in] ih handle of operation to cancel * @param[in] ph handle of operation to cancel
*/ */
static void static void
template_initiate_cancel (struct TALER_KYCLOGIC_InitiateHandle *ih) template_proof_cancel (struct TALER_KYCLOGIC_ProofHandle *ph)
{ {
GNUNET_break (0); // FIXME: add cancel logic here GNUNET_break (0); // FIXME: stop activities...
GNUNET_free (ih); GNUNET_free (ph);
} }
@ -280,6 +308,7 @@ template_proof (void *cls,
ph->pd = pd; ph->pd = pd;
ph->cb = cb; ph->cb = cb;
ph->cb_cls = cb_cls; ph->cb_cls = cb_cls;
ph->connection = connection;
GNUNET_break (0); // FIXME: start check! GNUNET_break (0); // FIXME: start check!
return ph; return ph;
@ -287,15 +316,15 @@ template_proof (void *cls,
/** /**
* Cancel KYC proof. * Cancel KYC webhook execution.
* *
* @param[in] ph handle of operation to cancel * @param[in] wh handle of operation to cancel
*/ */
static void static void
template_proof_cancel (struct TALER_KYCLOGIC_ProofHandle *ph) template_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
{ {
GNUNET_break (0); // FIXME: stop activities... GNUNET_break (0); /* FIXME: stop activity */
GNUNET_free (ph); GNUNET_free (wh);
} }
@ -334,24 +363,12 @@ template_webhook (void *cls,
wh->cb_cls = cb_cls; wh->cb_cls = cb_cls;
wh->ps = ps; wh->ps = ps;
wh->pd = pd; wh->pd = pd;
wh->connection = connection;
GNUNET_break (0); /* FIXME: start activity */ GNUNET_break (0); /* FIXME: start activity */
return wh; return wh;
} }
/**
* Cancel KYC webhook execution.
*
* @param[in] wh handle of operation to cancel
*/
static void
template_webhook_cancel (struct TALER_KYCLOGIC_WebhookHandle *wh)
{
GNUNET_break (0); /* FIXME: stop activity */
GNUNET_free (wh);
}
/** /**
* Initialize Template.0 KYC logic plugin * Initialize Template.0 KYC logic plugin
* *

View File

@ -1281,6 +1281,8 @@ initiate_cb (
cmd_provider_user_id = GNUNET_strdup (provider_user_id); cmd_provider_user_id = GNUNET_strdup (provider_user_id);
if (NULL != provider_legitimization_id) if (NULL != provider_legitimization_id)
cmd_provider_legitimization_id = GNUNET_strdup (provider_legitimization_id); cmd_provider_legitimization_id = GNUNET_strdup (provider_legitimization_id);
if (! run_webservice)
GNUNET_SCHEDULER_shutdown ();
} }