[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: move authorization plugins to t
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: move authorization plugins to their own directory |
Date: |
Mon, 08 Feb 2021 17:26:29 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new f62091a move authorization plugins to their own directory
f62091a is described below
commit f62091a2399ab94f57fbb63735b910b13b825223
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Feb 8 17:26:27 2021 +0100
move authorization plugins to their own directory
---
configure.ac | 1 +
src/Makefile.am | 2 +-
src/{backend => authorization}/Makefile.am | 36 ----------------
.../anastasis_authorization_plugin.c | 19 +++++---
.../anastasis_authorization_plugin_email.c | 0
.../anastasis_authorization_plugin_file.c | 5 ++-
.../anastasis_authorization_plugin_sms.c | 19 +++++++-
src/backend/Makefile.am | 50 +---------------------
src/backend/anastasis-httpd.c | 5 ++-
src/backend/anastasis-httpd.h | 4 +-
src/backend/anastasis-httpd_policy_upload.c | 4 +-
src/backend/anastasis-httpd_truth.c | 6 ++-
src/include/anastasis_authorization_plugin.h | 4 ++
13 files changed, 54 insertions(+), 101 deletions(-)
diff --git a/configure.ac b/configure.ac
index 67d2fc8..6daba46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -317,6 +317,7 @@ Makefile
contrib/Makefile
doc/Makefile
src/Makefile
+src/authorization/Makefile
src/backend/Makefile
src/cli/Makefile
src/include/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 11a3a36..5e006a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,3 @@
# This Makefile is in the public domain
AM_CPPFLAGS = -I$(top_srcdir)/src/include
-SUBDIRS = include util stasis backend restclient lib testing reducer cli
+SUBDIRS = include util stasis authorization backend restclient lib testing
reducer cli
diff --git a/src/backend/Makefile.am b/src/authorization/Makefile.am
similarity index 63%
copy from src/backend/Makefile.am
copy to src/authorization/Makefile.am
index 6b170f9..719258c 100644
--- a/src/backend/Makefile.am
+++ b/src/authorization/Makefile.am
@@ -55,39 +55,3 @@ libanastasis_plugin_authorization_sms_la_LDFLAGS = \
-ltalerutil \
-lgnunetutil \
$(XLIB)
-
-pkgcfg_DATA = \
- anastasis.conf
-
-bin_PROGRAMS = \
- anastasis-httpd
-
-anastasis_httpd_SOURCES = \
- anastasis-httpd.c anastasis-httpd.h \
- anastasis-httpd_mhd.c anastasis-httpd_mhd.h \
- anastasis-httpd_policy.c anastasis-httpd_policy.h \
- anastasis-httpd_policy_upload.c \
- anastasis-httpd_salt.c anastasis-httpd_salt.h \
- anastasis-httpd_truth.c anastasis-httpd_truth.h \
- anastasis-httpd_terms.c anastasis-httpd_terms.h \
- anastasis-httpd_config.c anastasis-httpd_config.h \
- anastasis-httpd_truth_upload.c
-
-anastasis_httpd_LDADD = \
- $(top_builddir)/src/util/libanastasisutil.la \
- $(top_builddir)/src/stasis/libanastasisdb.la \
- libanastasisauthorization.la \
- -lmicrohttpd \
- -ljansson \
- -ltalermerchant \
- -ltalermhd \
- -ltalerjson \
- -ltalerutil \
- -lgnunetcurl \
- -lgnunetrest \
- -lgnunetjson \
- -lgnunetutil \
- -luuid
-
-EXTRA_DIST = \
- $(pkgcfg_DATA)
diff --git a/src/backend/anastasis_authorization_plugin.c
b/src/authorization/anastasis_authorization_plugin.c
similarity index 94%
rename from src/backend/anastasis_authorization_plugin.c
rename to src/authorization/anastasis_authorization_plugin.c
index b1824ee..3a7f15b 100644
--- a/src/backend/anastasis_authorization_plugin.c
+++ b/src/authorization/anastasis_authorization_plugin.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2015, 2016 GNUnet e.V. and INRIA
+ Copyright (C) 2015, 2016, 2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software
@@ -21,7 +21,6 @@
*/
#include "platform.h"
#include "anastasis_authorization_plugin.h"
-#include "anastasis-httpd.h"
#include <ltdl.h>
@@ -84,7 +83,12 @@ ANASTASIS_authorization_plugin_load (
char *lib_name;
char *sec_name;
struct AuthPlugin *ap;
+ char *currency;
+ if (GNUNET_OK !=
+ TALER_config_get_currency (AH_cfg,
+ ¤cy))
+ return NULL;
for (ap = ap_head; NULL != ap; ap = ap->next)
if (0 == strcmp (method,
ap->name))
@@ -107,22 +111,25 @@ ANASTASIS_authorization_plugin_load (
sec_name,
"COST");
GNUNET_free (sec_name);
+ GNUNET_free (currency);
GNUNET_free (ap);
return NULL;
}
- // FIXME: AH_annual_fee is not a symbol of this library!!!
- if (GNUNET_OK !=
- TALER_amount_cmp_currency (&ap->cost,
- &AH_annual_fee))
+
+ if (0 !=
+ strcasecmp (currency,
+ ap->cost.currency))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
sec_name,
"COST",
"currency mismatch");
+ GNUNET_free (currency);
GNUNET_free (sec_name);
GNUNET_free (ap);
return NULL;
}
+ GNUNET_free (currency);
GNUNET_free (sec_name);
GNUNET_asprintf (&lib_name,
"libanastasis_plugin_authorization_%s",
diff --git a/src/backend/anastasis_authorization_plugin_email.c
b/src/authorization/anastasis_authorization_plugin_email.c
similarity index 100%
rename from src/backend/anastasis_authorization_plugin_email.c
rename to src/authorization/anastasis_authorization_plugin_email.c
diff --git a/src/backend/anastasis_authorization_plugin_file.c
b/src/authorization/anastasis_authorization_plugin_file.c
similarity index 97%
rename from src/backend/anastasis_authorization_plugin_file.c
rename to src/authorization/anastasis_authorization_plugin_file.c
index 691aaef..3d9b356 100644
--- a/src/backend/anastasis_authorization_plugin_file.c
+++ b/src/authorization/anastasis_authorization_plugin_file.c
@@ -19,7 +19,6 @@
* @author Dominik Meister
*/
#include "platform.h"
-#include "anastasis-httpd.h"
#include "anastasis_authorization_plugin.h"
#include <taler/taler_mhd_lib.h>
@@ -102,6 +101,8 @@ file_validate (void *cls,
* I.e. start to send SMS or e-mail or launch video identification.
*
* @param cls closure
+ * @param trigger function to call when we made progress
+ * @param trigger_cls closure for @a trigger
* @param truth_public_key Identifier of the challenge, to be (if possible)
included in the
* interaction with the user
* @param code secret code that the user has to provide back to satisfy the
challenge in
@@ -111,6 +112,8 @@ file_validate (void *cls,
*/
static struct ANASTASIS_AUTHORIZATION_State *
file_start (void *cls,
+ GNUNET_SCHEDULER_TaskCallback trigger,
+ void *trigger_cls,
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
uint64_t code,
const void *data,
diff --git a/src/backend/anastasis_authorization_plugin_sms.c
b/src/authorization/anastasis_authorization_plugin_sms.c
similarity index 96%
rename from src/backend/anastasis_authorization_plugin_sms.c
rename to src/authorization/anastasis_authorization_plugin_sms.c
index 579992c..5687643 100644
--- a/src/backend/anastasis_authorization_plugin_sms.c
+++ b/src/authorization/anastasis_authorization_plugin_sms.c
@@ -19,7 +19,6 @@
* @author Dominik Meister
*/
#include "platform.h"
-#include "anastasis-httpd.h"
#include "anastasis_authorization_plugin.h"
#include <taler/taler_mhd_lib.h>
#include <regex.h>
@@ -66,6 +65,16 @@ struct ANASTASIS_AUTHORIZATION_State
*/
struct SMS_Context *ctx;
+ /**
+ * Function to call when we made progress.
+ */
+ GNUNET_SCHEDULER_TaskCallback trigger;
+
+ /**
+ * Closure for @e trigger.
+ */
+ void *trigger_cls;
+
/**
* holds the truth information
*/
@@ -162,6 +171,8 @@ sms_validate (void *cls,
* Sends SMS.
*
* @param cls closure with a `struct SMS_Context`
+ * @param trigger function to call when we made progress
+ * @param trigger_cls closure for @a trigger
* @param truth_public_key Identifier of the challenge, to be (if possible)
included in the
* interaction with the user
* @param code secret code that the user has to provide back to satisfy the
challenge in
@@ -171,6 +182,8 @@ sms_validate (void *cls,
*/
static struct ANASTASIS_AUTHORIZATION_State *
sms_start (void *cls,
+ GNUNET_SCHEDULER_TaskCallback trigger,
+ void *trigger_cls,
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
uint64_t code,
const void *data,
@@ -180,6 +193,8 @@ sms_start (void *cls,
struct ANASTASIS_AUTHORIZATION_State *as;
as = GNUNET_new (struct ANASTASIS_AUTHORIZATION_State);
+ as->trigger = trigger;
+ as->trigger_cls = trigger_cls;
as->ctx = ctx;
as->truth_public_key = *truth_public_key;
as->code = code;
@@ -208,7 +223,7 @@ sms_done_cb (void *cls,
as->pst = type;
as->exit_code = exit_code;
MHD_resume_connection (as->connection);
- AH_trigger_daemon (); // FIXME: unclean, linker issue => change API to get a
callback?
+ as->trigger (as->trigger_cls);
}
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 6b170f9..143bfaf 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -2,60 +2,12 @@
AM_CPPFLAGS = -I$(top_srcdir)/src/include
pkgcfgdir = $(prefix)/share/anastasis/config.d/
-plugindir = $(libdir)/anastasis
if USE_COVERAGE
AM_CFLAGS = --coverage -O0
XLIB = -lgcov
endif
-lib_LTLIBRARIES = \
- libanastasisauthorization.la
-
-libanastasisauthorization_la_SOURCES = \
- anastasis_authorization_plugin.c
-libanastasisauthorization_la_LIBADD = \
- $(LTLIBINTL)
-libanastasisauthorization_la_LDFLAGS = \
- -talerutil \
- -lgnunetutil
-
-plugin_LTLIBRARIES = \
- libanastasis_plugin_authorization_file.la \
- libanastasis_plugin_authorization_sms.la
-libanastasis_plugin_authorization_file_la_SOURCES = \
- anastasis_authorization_plugin_file.c
-libanastasis_plugin_authorization_file_la_LIBADD = \
- $(LTLIBINTL)
-libanastasis_plugin_authorization_file_la_LDFLAGS = \
- $(ANASTASIS_PLUGIN_LDFLAGS) \
- -ljansson \
- -ltalerutil \
- -lgnunetutil \
- $(XLIB)
-
-#libanastasis_plugin_authorization_email_la_SOURCES = \
-# anastasis_authorization_plugin_email.c
-#libanastasis_plugin_authorization_email_la_LIBADD = \
-# $(LTLIBINTL)
-#libanastasis_plugin_authorization_email_la_LDFLAGS = \
-# $(ANASTASIS_PLUGIN_LDFLAGS) \
-# -ljansson \
-# -ltalerutil \
-# -lgnunetutil \
-# $(XLIB)
-
-libanastasis_plugin_authorization_sms_la_SOURCES = \
- anastasis_authorization_plugin_sms.c
-libanastasis_plugin_authorization_sms_la_LIBADD = \
- $(LTLIBINTL)
-libanastasis_plugin_authorization_sms_la_LDFLAGS = \
- $(ANASTASIS_PLUGIN_LDFLAGS) \
- -ljansson \
- -ltalerutil \
- -lgnunetutil \
- $(XLIB)
-
pkgcfg_DATA = \
anastasis.conf
@@ -76,7 +28,7 @@ anastasis_httpd_SOURCES = \
anastasis_httpd_LDADD = \
$(top_builddir)/src/util/libanastasisutil.la \
$(top_builddir)/src/stasis/libanastasisdb.la \
- libanastasisauthorization.la \
+ $(top_builddir)/src/authorization/libanastasisauthorization.la \
-lmicrohttpd \
-ljansson \
-ltalermerchant \
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 0dcecf1..7a97780 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -190,10 +190,13 @@ run_daemon (void *cls)
* Basically, we need to explicitly resume MHD's event loop whenever
* we made progress serving a request. This function re-schedules
* the task processing MHD's activities to run immediately.
+ *
+ * @param cls NULL
*/
void
-AH_trigger_daemon (void)
+AH_trigger_daemon (void *cls)
{
+ (void) cls;
if (NULL != mhd_task)
{
GNUNET_SCHEDULER_cancel (mhd_task);
diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h
index 7f50aff..4a98248 100644
--- a/src/backend/anastasis-httpd.h
+++ b/src/backend/anastasis-httpd.h
@@ -194,9 +194,11 @@ extern struct GNUNET_CURL_Context *AH_ctx;
* Basically, we need to explicitly resume MHD's event loop whenever
* we made progress serving a request. This function re-schedules
* the task processing MHD's activities to run immediately.
+ *
+ * @param cls NULL
*/
void
-AH_trigger_daemon (void);
+AH_trigger_daemon (void *cls);
/**
* Kick GNUnet Curl scheduler to begin curl interactions.
diff --git a/src/backend/anastasis-httpd_policy_upload.c
b/src/backend/anastasis-httpd_policy_upload.c
index f37cb39..af00d47 100644
--- a/src/backend/anastasis-httpd_policy_upload.c
+++ b/src/backend/anastasis-httpd_policy_upload.c
@@ -328,7 +328,7 @@ proposal_cb (void *cls,
puc_tail,
puc);
MHD_resume_connection (puc->con);
- AH_trigger_daemon ();
+ AH_trigger_daemon (NULL);
if (MHD_HTTP_OK != por->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -441,7 +441,7 @@ check_payment_cb (void *cls,
puc_tail,
puc);
MHD_resume_connection (puc->con);
- AH_trigger_daemon ();
+ AH_trigger_daemon (NULL);
switch (osr->status)
{
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index fd101ac..5bb73b4 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -229,7 +229,7 @@ proposal_cb (void *cls,
gc_tail,
gc);
MHD_resume_connection (gc->connection);
- AH_trigger_daemon ();
+ AH_trigger_daemon (NULL);
if (MHD_HTTP_OK != por->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -290,7 +290,7 @@ check_payment_cb (void *cls,
gc_tail,
gc);
MHD_resume_connection (gc->connection);
- AH_trigger_daemon ();
+ AH_trigger_daemon (NULL);
switch (hr->http_status)
{
@@ -925,6 +925,8 @@ AH_handler_truth_get (struct MHD_Connection *connection,
}
gc->as = gc->authorization->start (gc->authorization->cls,
+ &AH_trigger_daemon,
+ NULL,
&gc->truth_public_key,
code,
decrypted_truth,
diff --git a/src/include/anastasis_authorization_plugin.h
b/src/include/anastasis_authorization_plugin.h
index 7a69dc1..b41daa8 100644
--- a/src/include/anastasis_authorization_plugin.h
+++ b/src/include/anastasis_authorization_plugin.h
@@ -140,6 +140,8 @@ struct ANASTASIS_AuthorizationPlugin
* may also be startedin the @e process function).
*
* @param cls closure
+ * @param trigger function to call when we made progress
+ * @param trigger_cls closure for @a trigger
* @param truth_public_key Identifier of the challenge, to be (if possible)
included in the
* interaction with the user
* @param code secret code that the user has to provide back to satisfy the
challenge in
@@ -150,6 +152,8 @@ struct ANASTASIS_AuthorizationPlugin
*/
struct ANASTASIS_AUTHORIZATION_State *
(*start)(void *cls,
+ GNUNET_SCHEDULER_TaskCallback trigger,
+ void *trigger_cls,
const struct ANASTASIS_CRYPTO_TruthPublicKeyP *truth_public_key,
uint64_t code,
const void *data,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: move authorization plugins to their own directory,
gnunet <=