aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 14:40:17 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 14:40:17 +0200
commit6ab14a20690a499ad32e3f2ad448d64d4e6b65fc (patch)
tree7866fb31e10cd49b2bb00eaf23134945b506624d /src/reclaim
parent1d4f5263ae72c12a42ec166ec8b1769620baaeda (diff)
downloadgnunet-6ab14a20690a499ad32e3f2ad448d64d4e6b65fc.tar.gz
gnunet-6ab14a20690a499ad32e3f2ad448d64d4e6b65fc.zip
-fix various bugs
Diffstat (limited to 'src/reclaim')
-rw-r--r--src/reclaim/gnunet-service-reclaim.c4
-rw-r--r--src/reclaim/oidc_helper.c33
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c8
-rw-r--r--src/reclaim/plugin_rest_reclaim.c3
-rw-r--r--src/reclaim/reclaim_api.c2
5 files changed, 23 insertions, 27 deletions
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c
index d4d44c3fc..0cd8c10a5 100644
--- a/src/reclaim/gnunet-service-reclaim.c
+++ b/src/reclaim/gnunet-service-reclaim.c
@@ -850,8 +850,8 @@ consume_result_cb (void *cls,
850 struct ConsumeTicketResultMessage *crm; 850 struct ConsumeTicketResultMessage *crm;
851 struct GNUNET_MQ_Envelope *env; 851 struct GNUNET_MQ_Envelope *env;
852 char *data_tmp; 852 char *data_tmp;
853 size_t attrs_len; 853 size_t attrs_len = 0;
854 size_t attests_len; 854 size_t attests_len = 0;
855 855
856 if (GNUNET_OK != success) 856 if (GNUNET_OK != success)
857 { 857 {
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c
index cb99a749d..9b5938c43 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/reclaim/oidc_helper.c
@@ -162,8 +162,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
162 struct GNUNET_RECLAIM_AttributeListEntry *le; 162 struct GNUNET_RECLAIM_AttributeListEntry *le;
163 struct GNUNET_RECLAIM_AttestationListEntry *ale; 163 struct GNUNET_RECLAIM_AttestationListEntry *ale;
164 char *subject; 164 char *subject;
165 char *aggr_names_str;
166 char *aggr_sources_str;
167 char *source_name; 165 char *source_name;
168 char *attr_val_str; 166 char *attr_val_str;
169 char *attest_val_str; 167 char *attest_val_str;
@@ -171,7 +169,7 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
171 json_t *aggr_names; 169 json_t *aggr_names;
172 json_t *aggr_sources; 170 json_t *aggr_sources;
173 json_t *aggr_sources_jwt; 171 json_t *aggr_sources_jwt;
174 json_t *addr_claim; 172 json_t *addr_claim = NULL;
175 int num_attestations = 0; 173 int num_attestations = 0;
176 for (le = attrs->list_head; NULL != le; le = le->next) 174 for (le = attrs->list_head; NULL != le; le = le->next)
177 { 175 {
@@ -194,8 +192,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
194 // sub REQUIRED public key identity, not exceed 255 ASCII length 192 // sub REQUIRED public key identity, not exceed 255 ASCII length
195 json_object_set_new (body, "sub", json_string (subject)); 193 json_object_set_new (body, "sub", json_string (subject));
196 attest_val_str = NULL; 194 attest_val_str = NULL;
197 aggr_names_str = NULL;
198 aggr_sources_str = NULL;
199 source_name = NULL; 195 source_name = NULL;
200 int i = 0; 196 int i = 0;
201 for (ale = attests->list_head; NULL != ale; ale = ale->next) 197 for (ale = attests->list_head; NULL != ale; ale = ale->next)
@@ -237,8 +233,6 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
237 if (NULL == addr_claim) 233 if (NULL == addr_claim)
238 { 234 {
239 addr_claim = json_object (); 235 addr_claim = json_object ();
240 json_object_set_new (body, "address",
241 addr_claim);
242 } 236 }
243 json_object_set_new (addr_claim, le->attribute->name, 237 json_object_set_new (addr_claim, le->attribute->name,
244 json_string (attr_val_str)); 238 json_string (attr_val_str));
@@ -273,21 +267,17 @@ generate_userinfo_json(const struct GNUNET_CRYPTO_EcdsaPublicKey *sub_key,
273 GNUNET_free (source_name); 267 GNUNET_free (source_name);
274 } 268 }
275 } 269 }
270 if (NULL != addr_claim)
271 json_object_set_new (body, "address", addr_claim);
276 272
277 if (NULL != attest_val_str) 273 if (NULL != attest_val_str)
278 GNUNET_free (attest_val_str); 274 GNUNET_free (attest_val_str);
279 if (0 != i) 275 if (0 != i)
280 { 276 {
281 aggr_names_str = json_dumps (aggr_names, JSON_INDENT (0) | JSON_COMPACT); 277 json_object_set_new (body, "_claim_names", aggr_names);
282 aggr_sources_str = json_dumps (aggr_sources, JSON_INDENT (0) 278 json_object_set_new (body, "_claim_sources", aggr_sources);
283 | JSON_COMPACT);
284 json_object_set_new (body, "_claim_names", json_string (aggr_names_str));
285 json_object_set_new (body, "_claim_sources", json_string (
286 aggr_sources_str));
287 } 279 }
288 280
289 json_decref (aggr_names);
290 json_decref (aggr_sources);
291 return body; 281 return body;
292} 282}
293 283
@@ -611,7 +601,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
611 GNUNET_STRINGS_base64url_decode (code, strlen (code), 601 GNUNET_STRINGS_base64url_decode (code, strlen (code),
612 (void **) &code_payload); 602 (void **) &code_payload);
613 if (code_payload_len < sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) 603 if (code_payload_len < sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose)
614 + sizeof(struct GNUNET_CRYPTO_EcdhePublicKey)
615 + sizeof(struct OIDC_Parameters) 604 + sizeof(struct OIDC_Parameters)
616 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature)) 605 + sizeof(struct GNUNET_CRYPTO_EcdsaSignature))
617 { 606 {
@@ -624,8 +613,6 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
624 plaintext_len = code_payload_len; 613 plaintext_len = code_payload_len;
625 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose); 614 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose);
626 ptr = (char *) &purpose[1]; 615 ptr = (char *) &purpose[1];
627 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdhePublicKey);
628
629 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdsaSignature); 616 plaintext_len -= sizeof(struct GNUNET_CRYPTO_EcdsaSignature);
630 plaintext = ptr; 617 plaintext = ptr;
631 ptr += plaintext_len; 618 ptr += plaintext_len;
@@ -683,8 +670,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
683 if (0 != GNUNET_memcmp (audience, &ticket->audience)) 670 if (0 != GNUNET_memcmp (audience, &ticket->audience))
684 { 671 {
685 GNUNET_free (code_payload); 672 GNUNET_free (code_payload);
686 if (NULL != nonce_str) 673 if (NULL != *nonce_str)
687 GNUNET_free (nonce_str); 674 GNUNET_free (*nonce_str);
688 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 675 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
689 "Audience in ticket does not match client!\n"); 676 "Audience in ticket does not match client!\n");
690 return GNUNET_SYSERR; 677 return GNUNET_SYSERR;
@@ -696,8 +683,8 @@ OIDC_parse_authz_code (const struct GNUNET_CRYPTO_EcdsaPublicKey *audience,
696 &ticket->identity)) 683 &ticket->identity))
697 { 684 {
698 GNUNET_free (code_payload); 685 GNUNET_free (code_payload);
699 if (NULL != nonce_str) 686 if (NULL != *nonce_str)
700 GNUNET_free (nonce_str); 687 GNUNET_free (*nonce_str);
701 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signature of AuthZ code invalid!\n"); 688 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Signature of AuthZ code invalid!\n");
702 return GNUNET_SYSERR; 689 return GNUNET_SYSERR;
703 } 690 }
@@ -768,7 +755,7 @@ OIDC_access_token_new (const struct GNUNET_RECLAIM_Ticket *ticket)
768 * Parse an access token 755 * Parse an access token
769 */ 756 */
770int 757int
771OIDC_access_token_parse (const char*token, 758OIDC_access_token_parse (const char *token,
772 struct GNUNET_RECLAIM_Ticket **ticket) 759 struct GNUNET_RECLAIM_Ticket **ticket)
773{ 760{
774 if (sizeof (struct GNUNET_RECLAIM_Ticket) != 761 if (sizeof (struct GNUNET_RECLAIM_Ticket) !=
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index b294ba166..06e1b0061 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -631,6 +631,8 @@ do_userinfo_error (void *cls)
631 struct MHD_Response *resp; 631 struct MHD_Response *resp;
632 char *error; 632 char *error;
633 633
634 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
635 "Error: %s\n", handle->edesc);
634 GNUNET_asprintf (&error, 636 GNUNET_asprintf (&error,
635 "error=\"%s\", error_description=\"%s\"", 637 "error=\"%s\", error_description=\"%s\"",
636 handle->emsg, 638 handle->emsg,
@@ -2129,12 +2131,13 @@ consume_ticket (void *cls,
2129 char *result_str; 2131 char *result_str;
2130 handle->idp_op = NULL; 2132 handle->idp_op = NULL;
2131 2133
2134 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Attr: %s\n", attr->name);
2132 if (NULL == identity) 2135 if (NULL == identity)
2133 { 2136 {
2134 result_str = OIDC_generate_userinfo (&handle->ticket.identity, 2137 result_str = OIDC_generate_userinfo (&handle->ticket.identity,
2135 handle->attr_userinfo_list, 2138 handle->attr_userinfo_list,
2136 handle->attests_list); 2139 handle->attests_list);
2137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Userinfo: %s\n", result_str); 2140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Userinfo: %s\n", result_str);
2138 resp = GNUNET_REST_create_response (result_str); 2141 resp = GNUNET_REST_create_response (result_str);
2139 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 2142 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
2140 GNUNET_free (result_str); 2143 GNUNET_free (result_str);
@@ -2198,6 +2201,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2198 const struct EgoEntry *aud_ego; 2201 const struct EgoEntry *aud_ego;
2199 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey; 2202 const struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
2200 2203
2204 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Getting userinfo\n");
2201 GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY, 2205 GNUNET_CRYPTO_hash (OIDC_AUTHORIZATION_HEADER_KEY,
2202 strlen (OIDC_AUTHORIZATION_HEADER_KEY), 2206 strlen (OIDC_AUTHORIZATION_HEADER_KEY),
2203 &cache_key); 2207 &cache_key);
@@ -2263,7 +2267,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2263 GNUNET_free (authorization); 2267 GNUNET_free (authorization);
2264 return; 2268 return;
2265 } 2269 }
2266 2270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Consuming ticket\n");
2267 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego); 2271 privkey = GNUNET_IDENTITY_ego_get_private_key (aud_ego->ego);
2268 handle->attr_userinfo_list = 2272 handle->attr_userinfo_list =
2269 GNUNET_new (struct GNUNET_RECLAIM_AttributeList); 2273 GNUNET_new (struct GNUNET_RECLAIM_AttributeList);
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index eb442bc3b..c2d14825e 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -331,6 +331,7 @@ finished_cont (void *cls, int32_t success, const char *emsg)
331 331
332 resp = GNUNET_REST_create_response (emsg); 332 resp = GNUNET_REST_create_response (emsg);
333 MHD_add_response_header (resp, "Content-Type", "application/json"); 333 MHD_add_response_header (resp, "Content-Type", "application/json");
334 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
334 if (GNUNET_OK != success) 335 if (GNUNET_OK != success)
335 { 336 {
336 GNUNET_SCHEDULER_add_now (&do_error, handle); 337 GNUNET_SCHEDULER_add_now (&do_error, handle);
@@ -348,6 +349,7 @@ delete_finished_cb (void *cls, int32_t success, const char *emsg)
348 struct MHD_Response *resp; 349 struct MHD_Response *resp;
349 350
350 resp = GNUNET_REST_create_response (emsg); 351 resp = GNUNET_REST_create_response (emsg);
352 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
351 if (GNUNET_OK != success) 353 if (GNUNET_OK != success)
352 { 354 {
353 GNUNET_SCHEDULER_add_now (&do_error, handle); 355 GNUNET_SCHEDULER_add_now (&do_error, handle);
@@ -373,6 +375,7 @@ return_response (void *cls)
373 result_str = json_dumps (handle->resp_object, 0); 375 result_str = json_dumps (handle->resp_object, 0);
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
375 resp = GNUNET_REST_create_response (result_str); 377 resp = GNUNET_REST_create_response (result_str);
378 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
376 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 379 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
377 GNUNET_free (result_str); 380 GNUNET_free (result_str);
378 cleanup_handle (handle); 381 cleanup_handle (handle);
diff --git a/src/reclaim/reclaim_api.c b/src/reclaim/reclaim_api.c
index ff549fa71..d73241a6f 100644
--- a/src/reclaim/reclaim_api.c
+++ b/src/reclaim/reclaim_api.c
@@ -1572,6 +1572,8 @@ GNUNET_RECLAIM_ticket_consume (
1572 ctm->ticket = *ticket; 1572 ctm->ticket = *ticket;
1573 if (NULL != h->mq) 1573 if (NULL != h->mq)
1574 GNUNET_MQ_send_copy (h->mq, op->env); 1574 GNUNET_MQ_send_copy (h->mq, op->env);
1575 else
1576 reconnect(h);
1575 return op; 1577 return op;
1576} 1578}
1577 1579