aboutsummaryrefslogtreecommitdiff
path: root/src/identity-provider
diff options
context:
space:
mode:
authorSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-03-05 19:39:56 +0100
committerSchanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de>2018-03-05 19:39:56 +0100
commitbb5a41d072ab7964006cb68a45e043d856cb630e (patch)
treefd2fbf5bd6fdace3892a1ba2bdb712c81a485232 /src/identity-provider
parentd036b626b8eea15f99d91faf309843936289fde7 (diff)
downloadgnunet-bb5a41d072ab7964006cb68a45e043d856cb630e.tar.gz
gnunet-bb5a41d072ab7964006cb68a45e043d856cb630e.zip
start fixing gns
Diffstat (limited to 'src/identity-provider')
-rw-r--r--src/identity-provider/gnunet-service-identity-provider.c19
-rw-r--r--src/identity-provider/identity-provider.conf2
-rw-r--r--src/identity-provider/plugin_rest_identity_provider.c76
3 files changed, 46 insertions, 51 deletions
diff --git a/src/identity-provider/gnunet-service-identity-provider.c b/src/identity-provider/gnunet-service-identity-provider.c
index 265719d58..523eebf39 100644
--- a/src/identity-provider/gnunet-service-identity-provider.c
+++ b/src/identity-provider/gnunet-service-identity-provider.c
@@ -1668,7 +1668,6 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
1668 size_t size; 1668 size_t size;
1669 char *buf; 1669 char *buf;
1670 char *scope; 1670 char *scope;
1671 char *lookup_query;
1672 1671
1673 handle->lookup_request = NULL; 1672 handle->lookup_request = NULL;
1674 if (1 != rd_count) 1673 if (1 != rd_count)
@@ -1720,18 +1719,15 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
1720 1719
1721 for (scope = strtok (scopes, ","); NULL != scope; scope = strtok (NULL, ",")) 1720 for (scope = strtok (scopes, ","); NULL != scope; scope = strtok (NULL, ","))
1722 { 1721 {
1723 GNUNET_asprintf (&lookup_query,
1724 "%s.gnu",
1725 scope);
1726 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1722 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1727 "Looking up %s\n", lookup_query); 1723 "Looking up %s\n", scope);
1728 parallel_lookup = GNUNET_new (struct ParallelLookup); 1724 parallel_lookup = GNUNET_new (struct ParallelLookup);
1729 parallel_lookup->handle = handle; 1725 parallel_lookup->handle = handle;
1730 parallel_lookup->label = GNUNET_strdup (scope); 1726 parallel_lookup->label = GNUNET_strdup (scope);
1731 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get(); 1727 parallel_lookup->lookup_start_time = GNUNET_TIME_absolute_get();
1732 parallel_lookup->lookup_request 1728 parallel_lookup->lookup_request
1733 = GNUNET_GNS_lookup (gns_handle, 1729 = GNUNET_GNS_lookup (gns_handle,
1734 lookup_query, 1730 scope,
1735 &handle->ticket.identity, 1731 &handle->ticket.identity,
1736 GNUNET_GNSRECORD_TYPE_ID_ATTR, 1732 GNUNET_GNSRECORD_TYPE_ID_ATTR,
1737 GNUNET_GNS_LO_DEFAULT, 1733 GNUNET_GNS_LO_DEFAULT,
@@ -1740,7 +1736,7 @@ process_consume_abe_key (void *cls, uint32_t rd_count,
1740 GNUNET_CONTAINER_DLL_insert (handle->parallel_lookups_head, 1736 GNUNET_CONTAINER_DLL_insert (handle->parallel_lookups_head,
1741 handle->parallel_lookups_tail, 1737 handle->parallel_lookups_tail,
1742 parallel_lookup); 1738 parallel_lookup);
1743 GNUNET_free (lookup_query); 1739 GNUNET_free (scope);
1744 } 1740 }
1745 GNUNET_free (scopes); 1741 GNUNET_free (scopes);
1746 GNUNET_free (buf); 1742 GNUNET_free (buf);
@@ -1756,7 +1752,6 @@ handle_consume_ticket_message (void *cls,
1756{ 1752{
1757 struct ConsumeTicketHandle *ch; 1753 struct ConsumeTicketHandle *ch;
1758 struct IdpClient *idp = cls; 1754 struct IdpClient *idp = cls;
1759 char* lookup_query;
1760 char* rnd_label; 1755 char* rnd_label;
1761 1756
1762 ch = GNUNET_new (struct ConsumeTicketHandle); 1757 ch = GNUNET_new (struct ConsumeTicketHandle);
@@ -1769,22 +1764,18 @@ handle_consume_ticket_message (void *cls,
1769 ch->ticket = *((struct GNUNET_IDENTITY_PROVIDER_Ticket*)&cm[1]); 1764 ch->ticket = *((struct GNUNET_IDENTITY_PROVIDER_Ticket*)&cm[1]);
1770 rnd_label = GNUNET_STRINGS_data_to_string_alloc (&ch->ticket.rnd, 1765 rnd_label = GNUNET_STRINGS_data_to_string_alloc (&ch->ticket.rnd,
1771 sizeof (uint64_t)); 1766 sizeof (uint64_t));
1772 GNUNET_asprintf (&lookup_query,
1773 "%s.gnu",
1774 rnd_label);
1775 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1767 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1776 "Looking for ABE key under %s\n", lookup_query); 1768 "Looking for ABE key under %s\n", rnd_label);
1777 ch->lookup_start_time = GNUNET_TIME_absolute_get (); 1769 ch->lookup_start_time = GNUNET_TIME_absolute_get ();
1778 ch->lookup_request 1770 ch->lookup_request
1779 = GNUNET_GNS_lookup (gns_handle, 1771 = GNUNET_GNS_lookup (gns_handle,
1780 lookup_query, 1772 rnd_label,
1781 &ch->ticket.identity, 1773 &ch->ticket.identity,
1782 GNUNET_GNSRECORD_TYPE_ABE_KEY, 1774 GNUNET_GNSRECORD_TYPE_ABE_KEY,
1783 GNUNET_GNS_LO_DEFAULT, 1775 GNUNET_GNS_LO_DEFAULT,
1784 &process_consume_abe_key, 1776 &process_consume_abe_key,
1785 ch); 1777 ch);
1786 GNUNET_free (rnd_label); 1778 GNUNET_free (rnd_label);
1787 GNUNET_free (lookup_query);
1788 GNUNET_SERVICE_client_continue (idp->client); 1779 GNUNET_SERVICE_client_continue (idp->client);
1789} 1780}
1790 1781
diff --git a/src/identity-provider/identity-provider.conf b/src/identity-provider/identity-provider.conf
index b78af3553..ea0028933 100644
--- a/src/identity-provider/identity-provider.conf
+++ b/src/identity-provider/identity-provider.conf
@@ -14,7 +14,7 @@ DATABASE = sqlite
14 14
15[identity-rest-plugin] 15[identity-rest-plugin]
16#ADDRESS = https://identity.gnu:8000#/login 16#ADDRESS = https://identity.gnu:8000#/login
17ADDRESS = https://identity.gnu/ui/#/login 17ADDRESS = https://reclaim.id/ui/#/login
18PSW = secret 18PSW = secret
19EXPIRATION_TIME = 3600 19EXPIRATION_TIME = 3600
20 20
diff --git a/src/identity-provider/plugin_rest_identity_provider.c b/src/identity-provider/plugin_rest_identity_provider.c
index 3f9279d5c..7b4ebf2fc 100644
--- a/src/identity-provider/plugin_rest_identity_provider.c
+++ b/src/identity-provider/plugin_rest_identity_provider.c
@@ -409,6 +409,11 @@ struct RequestHandle
409 char *url; 409 char *url;
410 410
411 /** 411 /**
412 * The tld for redirect
413 */
414 char *tld;
415
416 /**
412 * Error response message 417 * Error response message
413 */ 418 */
414 char *emsg; 419 char *emsg;
@@ -457,6 +462,8 @@ cleanup_handle (struct RequestHandle *handle)
457 GNUNET_IDENTITY_PROVIDER_disconnect (handle->idp); 462 GNUNET_IDENTITY_PROVIDER_disconnect (handle->idp);
458 if (NULL != handle->url) 463 if (NULL != handle->url)
459 GNUNET_free (handle->url); 464 GNUNET_free (handle->url);
465 if (NULL != handle->tld)
466 GNUNET_free (handle->tld);
460 if (NULL != handle->emsg) 467 if (NULL != handle->emsg)
461 GNUNET_free (handle->emsg); 468 GNUNET_free (handle->emsg);
462 if (NULL != handle->edesc) 469 if (NULL != handle->edesc)
@@ -1463,6 +1470,8 @@ static void get_client_name_result (void *cls,
1463 char *code_base64_final_string; 1470 char *code_base64_final_string;
1464 char *redirect_path; 1471 char *redirect_path;
1465 char *tmp; 1472 char *tmp;
1473 char *tmp_prefix;
1474 char *prefix;
1466 ticket_str = GNUNET_STRINGS_data_to_string_alloc (&handle->ticket, 1475 ticket_str = GNUNET_STRINGS_data_to_string_alloc (&handle->ticket,
1467 sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket)); 1476 sizeof (struct GNUNET_IDENTITY_PROVIDER_Ticket));
1468 //TODO change if more attributes are needed (see max_age) 1477 //TODO change if more attributes are needed (see max_age)
@@ -1476,8 +1485,13 @@ static void get_client_name_result (void *cls,
1476 redirect_path = strtok (tmp, "/"); 1485 redirect_path = strtok (tmp, "/");
1477 redirect_path = strtok (NULL, "/"); 1486 redirect_path = strtok (NULL, "/");
1478 redirect_path = strtok (NULL, "/"); 1487 redirect_path = strtok (NULL, "/");
1479 GNUNET_asprintf (&redirect_uri, "https://%s.gnu/%s?%s=%s&state=%s", 1488 tmp_prefix = GNUNET_strdup (handle->oidc->redirect_uri);
1480 label, 1489 prefix = strrchr (tmp_prefix,
1490 (unsigned char) '.');
1491 *prefix = '\0';
1492 GNUNET_asprintf (&redirect_uri, "%s.%s/%s?%s=%s&state=%s",
1493 tmp_prefix,
1494 handle->tld,
1481 redirect_path, 1495 redirect_path,
1482 handle->oidc->response_type, 1496 handle->oidc->response_type,
1483 code_base64_final_string, handle->oidc->state); 1497 code_base64_final_string, handle->oidc->state);
@@ -1486,6 +1500,7 @@ static void get_client_name_result (void *cls,
1486 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); 1500 handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
1487 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); 1501 GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
1488 GNUNET_free (tmp); 1502 GNUNET_free (tmp);
1503 GNUNET_free (tmp_prefix);
1489 GNUNET_free (redirect_uri); 1504 GNUNET_free (redirect_uri);
1490 GNUNET_free (ticket_str); 1505 GNUNET_free (ticket_str);
1491 GNUNET_free (code_json_string); 1506 GNUNET_free (code_json_string);
@@ -1730,7 +1745,6 @@ static void namestore_iteration_finished (void *cls)
1730 struct RequestHandle *handle = cls; 1745 struct RequestHandle *handle = cls;
1731 struct GNUNET_HashCode cache_key; 1746 struct GNUNET_HashCode cache_key;
1732 1747
1733 char *expected_redirect_uri;
1734 char *expected_scope; 1748 char *expected_scope;
1735 char delimiter[]=" "; 1749 char delimiter[]=" ";
1736 int number_of_ignored_parameter, iterator; 1750 int number_of_ignored_parameter, iterator;
@@ -1766,23 +1780,9 @@ static void namestore_iteration_finished (void *cls)
1766 GNUNET_SCHEDULER_add_now (&do_error, handle); 1780 GNUNET_SCHEDULER_add_now (&do_error, handle);
1767 return; 1781 return;
1768 } 1782 }
1769 handle->oidc->redirect_uri = GNUNET_CONTAINER_multihashmap_get(handle->rest_handle->url_param_map, 1783 handle->oidc->redirect_uri = GNUNET_strdup (GNUNET_CONTAINER_multihashmap_get(handle->rest_handle->url_param_map,
1770 &cache_key); 1784 &cache_key));
1771 1785
1772 GNUNET_asprintf (&expected_redirect_uri, "https://%s.zkey", handle->oidc->client_id);
1773 // verify the redirect uri matches https://<client_id>.zkey[/xyz]
1774 if( 0 != strncmp( expected_redirect_uri, handle->oidc->redirect_uri, strlen(expected_redirect_uri)) )
1775 {
1776 handle->oidc->redirect_uri = NULL;
1777 handle->emsg=GNUNET_strdup("invalid_request");
1778 handle->edesc=GNUNET_strdup("Invalid redirect_uri");
1779 GNUNET_SCHEDULER_add_now (&do_error, handle);
1780 GNUNET_free(expected_redirect_uri);
1781 return;
1782 }
1783 handle->oidc->redirect_uri = GNUNET_strdup(handle->oidc->redirect_uri);
1784
1785 GNUNET_free(expected_redirect_uri);
1786 // REQUIRED value: response_type 1786 // REQUIRED value: response_type
1787 GNUNET_CRYPTO_hash (OIDC_RESPONSE_TYPE_KEY, strlen (OIDC_RESPONSE_TYPE_KEY), 1787 GNUNET_CRYPTO_hash (OIDC_RESPONSE_TYPE_KEY, strlen (OIDC_RESPONSE_TYPE_KEY),
1788 &cache_key); 1788 &cache_key);
@@ -1897,6 +1897,9 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1897{ 1897{
1898 struct RequestHandle *handle = cls; 1898 struct RequestHandle *handle = cls;
1899 struct GNUNET_HashCode cache_key; 1899 struct GNUNET_HashCode cache_key;
1900 struct EgoEntry *tmp_ego;
1901 struct GNUNET_CRYPTO_EcdsaPublicKey pkey;
1902 const struct GNUNET_CRYPTO_EcdsaPrivateKey *priv_key;
1900 1903
1901 cookie_identity_interpretation(handle); 1904 cookie_identity_interpretation(handle);
1902 1905
@@ -1922,9 +1925,8 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1922 GNUNET_SCHEDULER_add_now (&do_error, handle); 1925 GNUNET_SCHEDULER_add_now (&do_error, handle);
1923 return; 1926 return;
1924 } 1927 }
1925 handle->oidc->client_id = GNUNET_CONTAINER_multihashmap_get(handle->rest_handle->url_param_map, 1928 handle->oidc->client_id = GNUNET_strdup (GNUNET_CONTAINER_multihashmap_get(handle->rest_handle->url_param_map,
1926 &cache_key); 1929 &cache_key));
1927 handle->oidc->client_id = GNUNET_strdup (handle->oidc->client_id);
1928 1930
1929 if ( GNUNET_OK 1931 if ( GNUNET_OK
1930 != GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->oidc->client_id, 1932 != GNUNET_CRYPTO_ecdsa_public_key_from_string (handle->oidc->client_id,
@@ -1952,6 +1954,22 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
1952 handle->ego_entry = handle->ego_head; 1954 handle->ego_entry = handle->ego_head;
1953 handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego); 1955 handle->priv_key = *GNUNET_IDENTITY_ego_get_private_key (handle->ego_head->ego);
1954 handle->oidc->is_client_trusted = GNUNET_NO; 1956 handle->oidc->is_client_trusted = GNUNET_NO;
1957
1958 //First check if client_id is one of our egos; TODO: handle other TLD cases: Delegation, from config
1959 for (tmp_ego = handle->ego_head; NULL != tmp_ego; tmp_ego = tmp_ego->next)
1960 {
1961 priv_key = GNUNET_IDENTITY_ego_get_private_key (tmp_ego->ego);
1962 GNUNET_CRYPTO_ecdsa_key_get_public (priv_key,
1963 &pkey);
1964 if ( 0 == memcmp (&pkey, &handle->oidc->client_pkey,
1965 sizeof(struct GNUNET_CRYPTO_EcdsaPublicKey)) )
1966 {
1967 handle->tld = GNUNET_strdup (tmp_ego->identifier);
1968 handle->oidc->is_client_trusted = GNUNET_YES;
1969 handle->ego_entry = handle->ego_tail;
1970 }
1971 }
1972
1955 1973
1956 // Checks if client_id is valid: 1974 // Checks if client_id is valid:
1957 handle->namestore_handle_it = GNUNET_NAMESTORE_zone_iteration_start ( 1975 handle->namestore_handle_it = GNUNET_NAMESTORE_zone_iteration_start (
@@ -2217,20 +2235,6 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
2217 GNUNET_SCHEDULER_add_now (&do_error, handle); 2235 GNUNET_SCHEDULER_add_now (&do_error, handle);
2218 return; 2236 return;
2219 } 2237 }
2220 // check redirect_uri
2221 GNUNET_asprintf (&expected_redirect_uri, "https://%s.zkey", client_id);
2222 // verify the redirect uri matches https://<client_id>.zkey[/xyz]
2223 if( 0 != strncmp( expected_redirect_uri, redirect_uri, strlen(expected_redirect_uri)) )
2224 {
2225 GNUNET_free_non_null(user_psw);
2226 handle->emsg=GNUNET_strdup("invalid_request");
2227 handle->edesc=GNUNET_strdup("Invalid redirect_uri");
2228 handle->response_code = MHD_HTTP_BAD_REQUEST;
2229 GNUNET_SCHEDULER_add_now (&do_error, handle);
2230 GNUNET_free(expected_redirect_uri);
2231 return;
2232 }
2233 GNUNET_free(expected_redirect_uri);
2234 GNUNET_CRYPTO_hash (code, strlen (code), &cache_key); 2238 GNUNET_CRYPTO_hash (code, strlen (code), &cache_key);
2235 int i = 1; 2239 int i = 1;
2236 if ( GNUNET_SYSERR 2240 if ( GNUNET_SYSERR