diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-04 21:15:59 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-09 20:38:10 +0100 |
commit | ad342b7e0870185522c7dcb846e71029fcfda335 (patch) | |
tree | 22dfa48bc4334d6b381bdb76458eb4c078ff9ac6 /src/reclaim/plugin_rest_openid_connect.c | |
parent | 55f6d26b7424d660c99bc89f3677b20294e87a27 (diff) | |
download | gnunet-ad342b7e0870185522c7dcb846e71029fcfda335.tar.gz gnunet-ad342b7e0870185522c7dcb846e71029fcfda335.zip |
add attestation API
Diffstat (limited to 'src/reclaim/plugin_rest_openid_connect.c')
-rw-r--r-- | src/reclaim/plugin_rest_openid_connect.c | 85 |
1 files changed, 68 insertions, 17 deletions
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index 610f93dbe..345dbeed6 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -457,6 +457,12 @@ struct RequestHandle | |||
457 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; | 457 | struct GNUNET_RECLAIM_AttributeIterator *attr_it; |
458 | 458 | ||
459 | /** | 459 | /** |
460 | * Attestation iterator | ||
461 | */ | ||
462 | struct GNUNET_RECLAIM_AttestationIterator *attest_it; | ||
463 | |||
464 | |||
465 | /** | ||
460 | * Ticket iterator | 466 | * Ticket iterator |
461 | */ | 467 | */ |
462 | struct GNUNET_RECLAIM_TicketIterator *ticket_it; | 468 | struct GNUNET_RECLAIM_TicketIterator *ticket_it; |
@@ -529,7 +535,6 @@ struct RequestHandle | |||
529 | static void | 535 | static void |
530 | cleanup_handle (struct RequestHandle *handle) | 536 | cleanup_handle (struct RequestHandle *handle) |
531 | { | 537 | { |
532 | struct GNUNET_RECLAIM_AttributeListEntry *claim_entry; | ||
533 | struct EgoEntry *ego_entry; | 538 | struct EgoEntry *ego_entry; |
534 | struct EgoEntry *ego_tmp; | 539 | struct EgoEntry *ego_tmp; |
535 | 540 | ||
@@ -540,6 +545,8 @@ cleanup_handle (struct RequestHandle *handle) | |||
540 | GNUNET_IDENTITY_disconnect (handle->identity_handle); | 545 | GNUNET_IDENTITY_disconnect (handle->identity_handle); |
541 | if (NULL != handle->attr_it) | 546 | if (NULL != handle->attr_it) |
542 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); | 547 | GNUNET_RECLAIM_get_attributes_stop (handle->attr_it); |
548 | if (NULL != handle->attest_it) | ||
549 | GNUNET_RECLAIM_get_attestations_stop (handle->attest_it); | ||
543 | if (NULL != handle->ticket_it) | 550 | if (NULL != handle->ticket_it) |
544 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); | 551 | GNUNET_RECLAIM_ticket_iteration_stop (handle->ticket_it); |
545 | if (NULL != handle->idp) | 552 | if (NULL != handle->idp) |
@@ -961,7 +968,53 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
961 | 968 | ||
962 | 969 | ||
963 | static void | 970 | static void |
964 | oidc_collect_finished_cb (void *cls) | 971 | oidc_attest_collect_finished_cb (void *cls) |
972 | { | ||
973 | struct RequestHandle *handle = cls; | ||
974 | |||
975 | handle->attest_it = NULL; | ||
976 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp, | ||
977 | &handle->priv_key, | ||
978 | &handle->oidc->client_pkey, | ||
979 | handle->attr_list, | ||
980 | &oidc_ticket_issue_cb, | ||
981 | handle); | ||
982 | } | ||
983 | |||
984 | |||
985 | /** | ||
986 | * Collects all attributes for an ego if in scope parameter | ||
987 | */ | ||
988 | static void | ||
989 | oidc_attest_collect (void *cls, | ||
990 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | ||
991 | const struct GNUNET_RECLAIM_Attestation *attest) | ||
992 | { | ||
993 | struct RequestHandle *handle = cls; | ||
994 | struct GNUNET_RECLAIM_AttributeListEntry *le; | ||
995 | |||
996 | for (le = handle->attr_list->list_head; NULL != le; le = le->next) | ||
997 | { | ||
998 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_equal (&le->attribute->attestation, | ||
999 | &attest->id)) | ||
1000 | { | ||
1001 | struct GNUNET_RECLAIM_AttestationListEntry *ale; | ||
1002 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); | ||
1003 | ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name, | ||
1004 | attest->type, | ||
1005 | attest->data, | ||
1006 | attest->data_size); | ||
1007 | GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, | ||
1008 | handle->attests_list->list_tail, | ||
1009 | ale); | ||
1010 | } | ||
1011 | } | ||
1012 | GNUNET_RECLAIM_get_attestations_next (handle->attest_it); | ||
1013 | } | ||
1014 | |||
1015 | |||
1016 | static void | ||
1017 | oidc_attr_collect_finished_cb (void *cls) | ||
965 | { | 1018 | { |
966 | struct RequestHandle *handle = cls; | 1019 | struct RequestHandle *handle = cls; |
967 | 1020 | ||
@@ -974,6 +1027,17 @@ oidc_collect_finished_cb (void *cls) | |||
974 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); | 1027 | GNUNET_SCHEDULER_add_now (&do_redirect_error, handle); |
975 | return; | 1028 | return; |
976 | } | 1029 | } |
1030 | handle->attests_list = GNUNET_new (struct GNUNET_RECLAIM_AttestationList); | ||
1031 | handle->attest_it = | ||
1032 | GNUNET_RECLAIM_get_attestations_start (handle->idp, | ||
1033 | &handle->priv_key, | ||
1034 | &oidc_iteration_error, | ||
1035 | handle, | ||
1036 | &oidc_attest_collect, | ||
1037 | handle, | ||
1038 | &oidc_attest_collect_finished_cb, | ||
1039 | handle); | ||
1040 | |||
977 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp, | 1041 | handle->idp_op = GNUNET_RECLAIM_ticket_issue (handle->idp, |
978 | &handle->priv_key, | 1042 | &handle->priv_key, |
979 | &handle->oidc->client_pkey, | 1043 | &handle->oidc->client_pkey, |
@@ -989,8 +1053,7 @@ oidc_collect_finished_cb (void *cls) | |||
989 | static void | 1053 | static void |
990 | oidc_attr_collect (void *cls, | 1054 | oidc_attr_collect (void *cls, |
991 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, | 1055 | const struct GNUNET_CRYPTO_EcdsaPublicKey *identity, |
992 | const struct GNUNET_RECLAIM_Attribute *attr, | 1056 | const struct GNUNET_RECLAIM_Attribute *attr) |
993 | const struct GNUNET_RECLAIM_Attestation *attest) | ||
994 | { | 1057 | { |
995 | struct RequestHandle *handle = cls; | 1058 | struct RequestHandle *handle = cls; |
996 | struct GNUNET_RECLAIM_AttributeListEntry *le; | 1059 | struct GNUNET_RECLAIM_AttributeListEntry *le; |
@@ -1026,18 +1089,6 @@ oidc_attr_collect (void *cls, | |||
1026 | GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head, | 1089 | GNUNET_CONTAINER_DLL_insert (handle->attr_list->list_head, |
1027 | handle->attr_list->list_tail, | 1090 | handle->attr_list->list_tail, |
1028 | le); | 1091 | le); |
1029 | if (GNUNET_NO == GNUNET_RECLAIM_id_is_zero (&attr->attestation)) | ||
1030 | { | ||
1031 | struct GNUNET_RECLAIM_AttestationListEntry *ale; | ||
1032 | ale = GNUNET_new (struct GNUNET_RECLAIM_AttestationListEntry); | ||
1033 | ale->attestation = GNUNET_RECLAIM_attestation_new (attest->name, | ||
1034 | attest->type, | ||
1035 | attest->data, | ||
1036 | attest->data_size); | ||
1037 | GNUNET_CONTAINER_DLL_insert (handle->attests_list->list_head, | ||
1038 | handle->attests_list->list_tail, | ||
1039 | ale); | ||
1040 | } | ||
1041 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); | 1092 | GNUNET_RECLAIM_get_attributes_next (handle->attr_it); |
1042 | } | 1093 | } |
1043 | 1094 | ||
@@ -1104,7 +1155,7 @@ code_redirect (void *cls) | |||
1104 | handle, | 1155 | handle, |
1105 | &oidc_attr_collect, | 1156 | &oidc_attr_collect, |
1106 | handle, | 1157 | handle, |
1107 | &oidc_collect_finished_cb, | 1158 | &oidc_attr_collect_finished_cb, |
1108 | handle); | 1159 | handle); |
1109 | return; | 1160 | return; |
1110 | } | 1161 | } |