diff options
author | Markus Voggenreiter <Markus.Voggenreiter@tum.de> | 2019-11-08 12:06:54 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-01-13 13:31:05 +0100 |
commit | c0fce9ca75973a646f80372fcc08c059818ba548 (patch) | |
tree | 582ea825f44149594f3031a445f48fad79fa3724 /src/reclaim/plugin_rest_openid_connect.c | |
parent | 854dfdf7031a4e06322b592b1c583cb8301afeb4 (diff) | |
download | gnunet-c0fce9ca75973a646f80372fcc08c059818ba548.tar.gz gnunet-c0fce9ca75973a646f80372fcc08c059818ba548.zip |
JWT Plugin, Prepared Ticketing
Diffstat (limited to 'src/reclaim/plugin_rest_openid_connect.c')
-rw-r--r-- | src/reclaim/plugin_rest_openid_connect.c | 109 |
1 files changed, 84 insertions, 25 deletions
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 | */ |
978 | static void | 978 | static void |
979 | oidc_attr_collect (void *cls, | 979 | oidc_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) |