aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Voggenreiter <Markus.Voggenreiter@tum.de>2019-11-08 12:06:54 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-13 13:31:05 +0100
commitc0fce9ca75973a646f80372fcc08c059818ba548 (patch)
tree582ea825f44149594f3031a445f48fad79fa3724
parent854dfdf7031a4e06322b592b1c583cb8301afeb4 (diff)
downloadgnunet-c0fce9ca75973a646f80372fcc08c059818ba548.tar.gz
gnunet-c0fce9ca75973a646f80372fcc08c059818ba548.zip
JWT Plugin, Prepared Ticketing
-rw-r--r--src/reclaim-attribute/reclaim_attribute.c2
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c109
-rw-r--r--src/reclaim/plugin_rest_reclaim.c23
3 files changed, 85 insertions, 49 deletions
diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c
index 113ec7ef5..207bfb617 100644
--- a/src/reclaim-attribute/reclaim_attribute.c
+++ b/src/reclaim-attribute/reclaim_attribute.c
@@ -426,7 +426,7 @@ GNUNET_RECLAIM_ATTESTATION_reference_new (const char *attr_name,
426 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1); 426 GNUNET_memcpy (write_ptr, attr_name_tmp, strlen (attr_name_tmp) + 1);
427 attr->name = write_ptr; 427 attr->name = write_ptr;
428 428
429 write_ptr += strlen (attr_name) +1; 429 write_ptr += strlen (attr_name) + 1;
430 GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1); 430 GNUNET_memcpy (write_ptr, ref_value_tmp, strlen (ref_value_tmp) + 1);
431 attr->reference_value = write_ptr; 431 attr->reference_value = write_ptr;
432 432
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 435cc3bf3..2c4b75c3f 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -973,7 +973,7 @@ oidc_collect_finished_cb (void *cls)
973 973
974 974
975/** 975/**
976 * Collects all attributes for an ego if in scope parameter 976 * Collects all attributes/references for an ego if in scope parameter
977 */ 977 */
978static void 978static void
979oidc_attr_collect (void *cls, 979oidc_attr_collect (void *cls,
@@ -988,39 +988,95 @@ oidc_attr_collect (void *cls,
988 char *scope_variable; 988 char *scope_variable;
989 char delimiter[] = " "; 989 char delimiter[] = " ";
990 990
991 if ((NULL == attr->name) || (NULL == attr->data)) 991 if ((NULL == attr) && (NULL == reference))
992 { 992 {
993 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 993 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
994 return; 994 return;
995 } 995 }
996 996 if (NULL == attr)
997 scope_variables = GNUNET_strdup (handle->oidc->scope);
998 scope_variable = strtok (scope_variables, delimiter);
999 while (NULL != scope_variable)
1000 { 997 {
1001 if (0 == strcmp (attr->name, scope_variable)) 998 if ((NULL == reference->name) || (NULL == reference->reference_value))
1002 break; 999 {
1003 scope_variable = strtok (NULL, delimiter); 1000 return;
1001 }
1002 scope_variables = GNUNET_strdup (handle->oidc->scope);
1003 scope_variable = strtok (scope_variables, delimiter);
1004 while (NULL != scope_variable)
1005 {
1006 if (0 == strcmp (reference->name, scope_variable))
1007 break;
1008 scope_variable = strtok (NULL, delimiter);
1009 }
1010 if (NULL == scope_variable)
1011 {
1012 GNUNET_free (scope_variables);
1013 return;
1014 }
1015 GNUNET_free (scope_variables);
1016 // Store references as attributes as they only use the ID later
1017 const char *type_str = NULL;
1018 char *data;
1019 size_t data_size;
1020 uint32_t type;
1021 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
1022 type_str = "String";
1023 type = GNUNET_RECLAIM_ATTRIBUTE_typename_to_number (type_str);
1024 if (GNUNET_SYSERR ==(GNUNET_RECLAIM_ATTRIBUTE_string_to_value (type,
1025 reference->
1026 reference_value,
1027 (void **) &
1028 data,
1029 &data_size)))
1030 {
1031 return;
1032 }
1033 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (reference->name,
1034 type,
1035 data,
1036 data_size);
1037 le->claim->id = reference->id;
1038 le->claim->flag = 1;
1039
1040 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1041 handle->attr_list->list_tail,
1042 le);
1004 } 1043 }
1005 if (NULL == scope_variable) 1044 else
1006 { 1045 {
1007 GNUNET_RECLAIM_get_attributes_next (handle->attr_it); 1046 if ((NULL == attr->name) || (NULL == attr->data))
1047 {
1048 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1049 return;
1050 }
1051 scope_variables = GNUNET_strdup (handle->oidc->scope);
1052 scope_variable = strtok (scope_variables, delimiter);
1053 while (NULL != scope_variable)
1054 {
1055 if (0 == strcmp (attr->name, scope_variable))
1056 break;
1057 scope_variable = strtok (NULL, delimiter);
1058 }
1059 if (NULL == scope_variable)
1060 {
1061 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1062 GNUNET_free (scope_variables);
1063 return;
1064 }
1008 GNUNET_free (scope_variables); 1065 GNUNET_free (scope_variables);
1009 return; 1066
1067 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
1068 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
1069 attr->type,
1070 attr->data,
1071 attr->data_size);
1072 le->claim->id = attr->id;
1073 le->claim->flag = attr->flag;
1074
1075 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1076 handle->attr_list->list_tail,
1077 le);
1078 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1010 } 1079 }
1011 GNUNET_free (scope_variables);
1012
1013 le = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry);
1014 le->claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name,
1015 attr->type,
1016 attr->data,
1017 attr->data_size);
1018 le->claim->id = attr->id;
1019 le->claim->flag = attr->flag;
1020 GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head,
1021 handle->attr_list->list_tail,
1022 le);
1023 GNUNET_RECLAIM_get_attributes_next (handle->attr_it);
1024} 1080}
1025 1081
1026 1082
@@ -1456,6 +1512,9 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1456 handle->ego_entry = handle->ego_tail; 1512 handle->ego_entry = handle->ego_tail;
1457 } 1513 }
1458 } 1514 }
1515 handle->oidc->scope = get_url_parameter_copy (handle, OIDC_SCOPE_KEY);
1516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scope: %s\n",GNUNET_strdup (
1517 handle->oidc->scope));
1459 if (NULL == handle->tld) 1518 if (NULL == handle->tld)
1460 GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle); 1519 GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle);
1461 if (NULL == handle->tld) 1520 if (NULL == handle->tld)
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 3b3674112..16286444a 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -37,9 +37,6 @@
37#include "gnunet_rest_plugin.h" 37#include "gnunet_rest_plugin.h"
38#include "gnunet_signatures.h" 38#include "gnunet_signatures.h"
39#include "json_reclaim.h" 39#include "json_reclaim.h"
40#include <openssl/bio.h>
41#include <openssl/evp.h>
42
43/** 40/**
44 * REST root namespace 41 * REST root namespace
45 */ 42 */
@@ -1199,26 +1196,6 @@ parse_jwt (const struct GNUNET_RECLAIM_ATTESTATION_Claim *attest,
1199 jwt_body = strtok (NULL, delim); 1196 jwt_body = strtok (NULL, delim);
1200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "JWT Body: %s\n", 1197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "JWT Body: %s\n",
1201 jwt_body); 1198 jwt_body);
1202 /*const char* jwt_base64 = jwt_body;
1203 //No padding assumed
1204 int jwt_len = (strlen(jwt_base64)*3)/4;
1205 BIO *bio, *b64;
1206 decoded_jwt = (char *) malloc(jwt_len + 1);
1207
1208 decoded_jwt[jwt_len] = '\0';
1209
1210 bio = BIO_new_mem_buf(jwt_base64, -1);
1211 b64 = BIO_new(BIO_f_base64());
1212 bio = BIO_push(b64, bio);
1213 BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
1214 /**length = BIO_read(bio, *buffer, strlen(jwt_base64));
1215 assert(*length == jwt_len); //length should equal jwt_len, else something went horribly wrong
1216
1217 BIO_free_all(bio);
1218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Parsed JWT Body: %s\n",
1219 decoded_jwt);
1220*/
1221
1222 1199
1223 val_str = "String from JWT, which is stored under claim"; 1200 val_str = "String from JWT, which is stored under claim";
1224 type_str = "String"; 1201 type_str = "String";