diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-16 11:17:19 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-16 11:17:19 +0200 |
commit | 7bed96f8e479af98db1a8a0c71b7c2ff2dc2b564 (patch) | |
tree | 85f7bd7cbe5dd507ed91cc2b53a09bbfb23505f6 | |
parent | c1c40eaa24926273a6aa688e92e99d832aa1501e (diff) | |
download | anastasis-7bed96f8e479af98db1a8a0c71b7c2ff2dc2b564.tar.gz anastasis-7bed96f8e479af98db1a8a0c71b7c2ff2dc2b564.zip |
allow setting api key via configuration
-rw-r--r-- | src/backend/anastasis-httpd.c | 15 | ||||
-rw-r--r-- | src/backend/anastasis-httpd_truth.c | 3 | ||||
-rw-r--r-- | src/backend/anastasis.conf | 35 | ||||
-rw-r--r-- | src/cli/test_reducer.conf | 4 | ||||
-rw-r--r-- | src/stasis/test_anastasis_db.c | 25 | ||||
-rw-r--r-- | src/testing/test_anastasis_api.conf | 12 |
6 files changed, 46 insertions, 48 deletions
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c index 8350ee7..fd5ffc3 100644 --- a/src/backend/anastasis-httpd.c +++ b/src/backend/anastasis-httpd.c | |||
@@ -708,12 +708,12 @@ run (void *cls, | |||
708 | } | 708 | } |
709 | if (GNUNET_OK != | 709 | if (GNUNET_OK != |
710 | GNUNET_CONFIGURATION_get_value_string (config, | 710 | GNUNET_CONFIGURATION_get_value_string (config, |
711 | "anastasis", | 711 | "anastasis-merchant-backend", |
712 | "PAYMENT_BACKEND_URL", | 712 | "PAYMENT_BACKEND_URL", |
713 | &AH_backend_url)) | 713 | &AH_backend_url)) |
714 | { | 714 | { |
715 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 715 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
716 | "anastasis", | 716 | "anastasis-merchant-backend", |
717 | "PAYMENT_BACKEND_URL"); | 717 | "PAYMENT_BACKEND_URL"); |
718 | GNUNET_SCHEDULER_shutdown (); | 718 | GNUNET_SCHEDULER_shutdown (); |
719 | return; | 719 | return; |
@@ -726,7 +726,7 @@ run (void *cls, | |||
726 | strlen ("http://"))) ) | 726 | strlen ("http://"))) ) |
727 | { | 727 | { |
728 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 728 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
729 | "anastasis", | 729 | "anastasis-merchant-backend", |
730 | "PAYMENT_BACKEND_URL", | 730 | "PAYMENT_BACKEND_URL", |
731 | "Must be HTTP(S) URL"); | 731 | "Must be HTTP(S) URL"); |
732 | GNUNET_SCHEDULER_shutdown (); | 732 | GNUNET_SCHEDULER_shutdown (); |
@@ -739,7 +739,7 @@ run (void *cls, | |||
739 | AH_backend_url)) ) | 739 | AH_backend_url)) ) |
740 | { | 740 | { |
741 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 741 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
742 | "anastasis", | 742 | "anastasis-merchant-backend", |
743 | "PAYMENT_BACKEND_URL", | 743 | "PAYMENT_BACKEND_URL", |
744 | "Must have domain name"); | 744 | "Must have domain name"); |
745 | GNUNET_SCHEDULER_shutdown (); | 745 | GNUNET_SCHEDULER_shutdown (); |
@@ -823,6 +823,13 @@ run (void *cls, | |||
823 | certfile, | 823 | certfile, |
824 | keyfile, | 824 | keyfile, |
825 | keypass); | 825 | keypass); |
826 | if (NULL == apikey) | ||
827 | { | ||
828 | (void) GNUNET_CONFIGURATION_get_value_string (config, | ||
829 | "anastasis-merchant-backend", | ||
830 | "API_KEY", | ||
831 | &apikey); | ||
832 | } | ||
826 | if (NULL != apikey) | 833 | if (NULL != apikey) |
827 | { | 834 | { |
828 | char *auth_header; | 835 | char *auth_header; |
diff --git a/src/backend/anastasis-httpd_truth.c b/src/backend/anastasis-httpd_truth.c index ee0f2bf..0b9f4a3 100644 --- a/src/backend/anastasis-httpd_truth.c +++ b/src/backend/anastasis-httpd_truth.c | |||
@@ -1192,7 +1192,8 @@ AH_handler_truth_get ( | |||
1192 | GNUNET_free (method); | 1192 | GNUNET_free (method); |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | if (! gc->authorization->payment_plugin_managed) | 1195 | if ( (is_question) || |
1196 | (! gc->authorization->payment_plugin_managed) ) | ||
1196 | { | 1197 | { |
1197 | struct TALER_Amount zero_amount; | 1198 | struct TALER_Amount zero_amount; |
1198 | 1199 | ||
diff --git a/src/backend/anastasis.conf b/src/backend/anastasis.conf index 23015ae..c10973c 100644 --- a/src/backend/anastasis.conf +++ b/src/backend/anastasis.conf | |||
@@ -30,7 +30,7 @@ DB = postgres | |||
30 | # ANNUAL_FEE = TESTKUDOS:0.1 | 30 | # ANNUAL_FEE = TESTKUDOS:0.1 |
31 | 31 | ||
32 | # Number of policy uploads included in one annual fee payment | 32 | # Number of policy uploads included in one annual fee payment |
33 | ANNUAL_POLICY_UPLÄOAD_LIMIT = 64 | 33 | ANNUAL_POLICY_UPLOAD_LIMIT = 64 |
34 | 34 | ||
35 | # Insurance | 35 | # Insurance |
36 | # INSURANCE = TESTKUDOS:1.0 | 36 | # INSURANCE = TESTKUDOS:1.0 |
@@ -43,35 +43,16 @@ UPLOAD_LIMIT_MB = 16 | |||
43 | # Cost of authentication by question | 43 | # Cost of authentication by question |
44 | #QUESTION_COST = EUR:0 | 44 | #QUESTION_COST = EUR:0 |
45 | 45 | ||
46 | # Cost of authentication by file (only for testing purposes) | ||
47 | #FILE_COST = EUR:1 | ||
48 | |||
49 | # Cost of authentication by E-Mail | ||
50 | #EMAIL_COST = EUR:0 | ||
51 | |||
52 | # Cost of authentication by SMS | ||
53 | #SMS_COST = EUR:0 | ||
54 | |||
55 | # Cost of authentication by postal | ||
56 | #POSTAL_COST = EUR:0 | ||
57 | |||
58 | # Cost of authentication by video | ||
59 | #VIDEO_COST = EUR:0 | ||
60 | |||
61 | #SMS authentication command which is executed | ||
62 | #SMSAUTH_COMMAND = some_sms_script.sh | ||
63 | |||
64 | #E-Mail authentication command which is executed | ||
65 | #EMAILAUTH_COMMAND = some_email_script.sh | ||
66 | |||
67 | # Fulfillment URL of the ANASTASIS service itself. | 46 | # Fulfillment URL of the ANASTASIS service itself. |
68 | FULFILLMENT_URL = taler://fulfillment-success | 47 | FULFILLMENT_URL = taler://fulfillment-success |
69 | 48 | ||
70 | # Base URL of our payment backend | ||
71 | # PAYMENT_BACKEND_URL = http://localhost:9976/ | ||
72 | |||
73 | # Server salt 16 Byte | 49 | # Server salt 16 Byte |
74 | # SERVER_SALT = gUfO1KGOKYIFlFQg | 50 | # SERVER_SALT = gUfO1KGOKYIFlFQg |
75 | 51 | ||
76 | # Supported methods | 52 | |
77 | SUPPORTED_METHODS = question | 53 | [anastasis-merchant-backend] |
54 | # Base URL of our payment backend | ||
55 | # PAYMENT_BACKEND_URL = http://localhost:9976/ | ||
56 | |||
57 | # API Key to send to the backend for authorization | ||
58 | # API_KEY = | ||
diff --git a/src/cli/test_reducer.conf b/src/cli/test_reducer.conf index f2a5efd..ef923bb 100644 --- a/src/cli/test_reducer.conf +++ b/src/cli/test_reducer.conf | |||
@@ -11,13 +11,15 @@ CURRENCY_ROUND_UNIT = TESTKUDOS:0.01 | |||
11 | 11 | ||
12 | [anastasis] | 12 | [anastasis] |
13 | DB = postgres | 13 | DB = postgres |
14 | PAYMENT_BACKEND_URL = http://localhost:9966/ | ||
15 | ANNUAL_FEE = TESTKUDOS:4.99 | 14 | ANNUAL_FEE = TESTKUDOS:4.99 |
16 | TRUTH_UPLOAD_FEE = TESTKUDOS:0.01 | 15 | TRUTH_UPLOAD_FEE = TESTKUDOS:0.01 |
17 | UPLOAD_LIMIT_MB = 1 | 16 | UPLOAD_LIMIT_MB = 1 |
18 | ANNUAL_POLICY_UPLOAD_LIMIT = 128 | 17 | ANNUAL_POLICY_UPLOAD_LIMIT = 128 |
19 | INSURANCE = TESTKUDOS:1.0 | 18 | INSURANCE = TESTKUDOS:1.0 |
20 | 19 | ||
20 | [anastasis-merchant-backend] | ||
21 | PAYMENT_BACKEND_URL = http://localhost:9966/ | ||
22 | |||
21 | [authorization-question] | 23 | [authorization-question] |
22 | COST = TESTKUDOS:0.0 | 24 | COST = TESTKUDOS:0.0 |
23 | 25 | ||
diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c index 54d665e..8f11827 100644 --- a/src/stasis/test_anastasis_db.c +++ b/src/stasis/test_anastasis_db.c | |||
@@ -268,18 +268,23 @@ run (void *cls) | |||
268 | } | 268 | } |
269 | ANASTASIS_hash_answer (123, | 269 | ANASTASIS_hash_answer (123, |
270 | &c_hash); | 270 | &c_hash); |
271 | FAILIF (ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH != | 271 | { |
272 | plugin->verify_challenge_code (plugin->cls, | 272 | bool sat; |
273 | &truth_uuid, | ||
274 | &c_hash)); | ||
275 | 273 | ||
276 | ANASTASIS_hash_answer (challenge_code, | 274 | FAILIF (ANASTASIS_DB_CODE_STATUS_CHALLENGE_CODE_MISMATCH != |
277 | &c_hash); | 275 | plugin->verify_challenge_code (plugin->cls, |
278 | FAILIF (ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED != | 276 | &truth_uuid, |
279 | plugin->verify_challenge_code (plugin->cls, | 277 | &c_hash, |
280 | &truth_uuid, | 278 | &sat)); |
281 | &c_hash)); | ||
282 | 279 | ||
280 | ANASTASIS_hash_answer (challenge_code, | ||
281 | &c_hash); | ||
282 | FAILIF (ANASTASIS_DB_CODE_STATUS_VALID_CODE_STORED != | ||
283 | plugin->verify_challenge_code (plugin->cls, | ||
284 | &truth_uuid, | ||
285 | &c_hash, | ||
286 | &sat)); | ||
287 | } | ||
283 | if (-1 == result) | 288 | if (-1 == result) |
284 | result = 0; | 289 | result = 0; |
285 | 290 | ||
diff --git a/src/testing/test_anastasis_api.conf b/src/testing/test_anastasis_api.conf index 65c05b3..8befd99 100644 --- a/src/testing/test_anastasis_api.conf +++ b/src/testing/test_anastasis_api.conf | |||
@@ -56,11 +56,6 @@ INSURANCE = EUR:0 | |||
56 | 56 | ||
57 | SERVER_SALT = salty | 57 | SERVER_SALT = salty |
58 | 58 | ||
59 | # Base URL of anastasis. | ||
60 | # BASE_URL = http://localhost:8086/ | ||
61 | |||
62 | # Where does our payment backend run? Must match PORT under [merchant] | ||
63 | PAYMENT_BACKEND_URL = http://localhost:8080/ | ||
64 | 59 | ||
65 | # Annual fee we charge. | 60 | # Annual fee we charge. |
66 | #ANNUAL_FEE = EUR:4.99 | 61 | #ANNUAL_FEE = EUR:4.99 |
@@ -68,6 +63,13 @@ ANNUAL_FEE = EUR:4.99 | |||
68 | 63 | ||
69 | TRUTH_UPLOAD_FEE = EUR:0.0 | 64 | TRUTH_UPLOAD_FEE = EUR:0.0 |
70 | 65 | ||
66 | # Base URL of anastasis. | ||
67 | # BASE_URL = http://localhost:8086/ | ||
68 | |||
69 | [anastasis-merchant-backend] | ||
70 | # Where does our payment backend run? Must match PORT under [merchant] | ||
71 | PAYMENT_BACKEND_URL = http://localhost:8080/ | ||
72 | |||
71 | # Authentication costs | 73 | # Authentication costs |
72 | [authorization-question] | 74 | [authorization-question] |
73 | # Cost of authentication by question | 75 | # Cost of authentication by question |