From 87bc2f469bf120bbd57e98a0a8ea46e80de84927 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 19 Aug 2021 12:25:34 +0200 Subject: -update IBAN plugin, write man page for anastasis-helper-authorization-iban --- .../anastasis-helper-authorization-iban.1.rst | 57 +++++++++++++++++++ doc/sphinx/manpages/anastasis.conf.5.rst | 39 +++++++++++-- .../anastasis-helper-authorization-iban.c | 66 +++++++++++++++++++++- .../anastasis_authorization_plugin_iban.c | 18 ------ 4 files changed, 156 insertions(+), 24 deletions(-) create mode 100644 doc/sphinx/manpages/anastasis-helper-authorization-iban.1.rst diff --git a/doc/sphinx/manpages/anastasis-helper-authorization-iban.1.rst b/doc/sphinx/manpages/anastasis-helper-authorization-iban.1.rst new file mode 100644 index 0000000..8674510 --- /dev/null +++ b/doc/sphinx/manpages/anastasis-helper-authorization-iban.1.rst @@ -0,0 +1,57 @@ +anastasis-helper-authorization-iban(1) +###################################### + +.. only:: html + + Name + ==== + + **anastasis-helper-authorization-iban** - Helper for IBAN authentication + +Synopsis +======== + +**anastasis-helper-authorization-iban** +[**-c** *FILENAME* | **––config=**\ ‌\ *FILENAME*] +[**-h** | **––help**] +[**-L** *LOGLEVEL* | **––loglevel=**\ ‌\ *LOGLEVEL*] +[**-l** *FILENAME* | **––logfile=**\ ‌\ *FILENAME*] +[**-t** | **––test**] +[**-v** | **––version**] + + +Description +=========== + +**anastasis-helper-authorization-iban** monitors the Anastasis provider's bank account for incoming wire transfers. This process supports the IBAN authentication method. It must be configured with the respective wire configuration to talk to LibEuFin/Nexus. + + +**-c** *FILENAME* \| **––config=**\ ‌\ *FILENAME* + Use the configuration from *FILENAME*. + +**-h** \| **––help** + Print short help on options. + +**-L** *LOGLEVEL* \| **––loglevel=**\ ‌\ *LOGLEVEL* + Specifies the log level to use. Accepted values are: ``DEBUG``, ``INFO``, + ``WARNING``, ``ERROR``. + +**-l** *FILENAME* \| **––logfile=**\ ‌\ *FILENAME* + Send logging output to *FILENAME*. + +**-t** \| **––test** + Run in test mode. Causes the process to terminate after importing current wire transfers instead of running forever in the background. + +**-v** \| **––version** + Print version information. + +See Also +======== + +anastasis-httpd(1), anastasis.conf(5). + +Bugs +==== + +Report bugs by using https://bugs.anastasis.lu/ or by sending electronic +mail to . diff --git a/doc/sphinx/manpages/anastasis.conf.5.rst b/doc/sphinx/manpages/anastasis.conf.5.rst index 1819d6d..40a3b7e 100644 --- a/doc/sphinx/manpages/anastasis.conf.5.rst +++ b/doc/sphinx/manpages/anastasis.conf.5.rst @@ -104,9 +104,11 @@ API_KEY Authorization options --------------------- -For each active authorization plugin, options must be configured in -a section called ``[authorization-$PLUGIN]`` where ``$PLUGIN`` is -the name of the authorization plugin. +For each active authorization plugin, options must be configured in a +section called ``[authorization-$PLUGIN]`` where ``$PLUGIN`` is the +name of the authorization plugin. Specific plugins may require +additional options, which are described in the respective sections +below. COST Fee the user has to pay to obtain a challenge from this @@ -115,8 +117,37 @@ COST ENABLED ``yes`` to enable this plugin, ``no`` to disable. + +SMS Authorization options +^^^^^^^^^^^^^^^^^^^^^^^^^ + +COMMAND + Helper command to run to send SMS. + +Email Authorization options +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + COMMAND - Helper command to run (only relevant for some plugins). + Helper command to run to send E-mail. + + +Post Authorization options +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +COMMAND + Helper command to run to send physical mail. + + +IBAN Authorization options +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +CREDIT_IBAN + IBAN number where the consumers must + wire the money to for authentication. + +BUSINESS_NAME + Name of the account holder. + Postgres database configuration diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c index f908b72..0d3200a 100644 --- a/src/authorization/anastasis-helper-authorization-iban.c +++ b/src/authorization/anastasis-helper-authorization-iban.c @@ -19,7 +19,6 @@ * @author Christian Grothoff * * TODO: - * - needs to load authentication information * - needs to add DB triggers to notify main service of inbound activity * - needs man page */ @@ -139,6 +138,7 @@ shutdown_task (void *cls) } ANASTASIS_DB_plugin_unload (db_plugin); db_plugin = NULL; + ANASTASIS_EUFIN_auth_free (&auth); cfg = NULL; } @@ -293,7 +293,68 @@ run (void *cls, global_ret = EXIT_NOTCONFIGURED; return; } - // FIXME: initialize 'auth' from cfg! + { + char *iban; + char *receiver_name; + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "authorization-iban", + "CREDIT_IBAN", + &iban)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "authorization-iban", + "CREDIT_IBAN"); + global_ret = EXIT_NOTCONFIGURED; + ANASTASIS_DB_plugin_unload (db_plugin); + db_plugin = NULL; + return; + } + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (cfg, + "authorization-iban", + "BUSINESS_NAME", + &receiver_name)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "authorization-iban", + "BUSINESS_NAME"); + global_ret = EXIT_NOTCONFIGURED; + ANASTASIS_DB_plugin_unload (db_plugin); + db_plugin = NULL; + return; + } + { + size_t len; + char *uri_receiver_name; + + len = GNUNET_STRINGS_urlencode (receiver_name, + strlen (receiver_name), + &uri_receiver_name); + GNUNET_assert (uri_receiver_name[len] == '\0'); + GNUNET_asprintf (&credit_account_uri, + "payto://iban/%s?receiver-name=%s", + iban, + uri_receiver_name); + GNUNET_free (uri_receiver_name); + } + GNUNET_free (iban); + GNUNET_free (receiver_name); + } + + if (GNUNET_OK != + ANASTASIS_EUFIN_auth_parse_cfg (cfg, + "authorization-iban", + &auth)) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Failed to load bank access configuration data\n"); + ANASTASIS_DB_plugin_unload (db_plugin); + db_plugin = NULL; + global_ret = EXIT_NOTCONFIGURED; + return; + } { enum GNUNET_DB_QueryStatus qs; @@ -303,6 +364,7 @@ run (void *cls, if (qs < 0) { GNUNET_break (0); + ANASTASIS_EUFIN_auth_free (&auth); ANASTASIS_DB_plugin_unload (db_plugin); db_plugin = NULL; return; diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c index 548b5c0..eee8e7e 100644 --- a/src/authorization/anastasis_authorization_plugin_iban.c +++ b/src/authorization/anastasis_authorization_plugin_iban.c @@ -20,7 +20,6 @@ */ #include "platform.h" #include "anastasis_authorization_plugin.h" -#include #include #include #include @@ -35,11 +34,6 @@ struct IBAN_Context { - /** - * Authentication data to access our bank account. - */ - struct TALER_BANK_AuthenticationData auth; - /** * Messages of the plugin, read from a resource file. */ @@ -533,17 +527,6 @@ libanastasis_plugin_authorization_iban_init (void *cls) GNUNET_free (fn); } ctx->ac = ac; - if (GNUNET_OK != - TALER_BANK_auth_parse_cfg (cfg, - "authorization-iban", - &ctx->auth)) - { - json_decref (ctx->messages); - GNUNET_free (ctx->business_iban); - GNUNET_free (ctx->business_name); - GNUNET_free (ctx); - return NULL; - } plugin = GNUNET_new (struct ANASTASIS_AuthorizationPlugin); plugin->payment_plugin_managed = true; plugin->code_validity_period = GNUNET_TIME_UNIT_MONTHS; @@ -571,7 +554,6 @@ libanastasis_plugin_authorization_iban_done (void *cls) struct ANASTASIS_AuthorizationPlugin *plugin = cls; struct IBAN_Context *ctx = plugin->cls; - TALER_BANK_auth_free (&ctx->auth); json_decref (ctx->messages); GNUNET_free (ctx->business_iban); GNUNET_free (ctx->business_name); -- cgit v1.2.3