gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] 43/45: -wip token endpoint refactor


From: gnunet
Subject: [GNUnet-SVN] [gnunet] 43/45: -wip token endpoint refactor
Date: Sun, 25 Feb 2018 16:25:47 +0100

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

commit faf1fef1ed824ca5f7692ac8a6a50f5f35352b0e
Author: Phil <address@hidden>
AuthorDate: Mon Feb 12 14:57:28 2018 +0100

    -wip token endpoint refactor
---
 src/identity-provider/jwt.c                        |  2 +-
 .../plugin_rest_identity_provider.c                | 57 ++++++++++++++--------
 src/rest/gnunet-rest-server.c                      | 12 ++---
 3 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/src/identity-provider/jwt.c b/src/identity-provider/jwt.c
index ede5424c8..ff3676cb6 100644
--- a/src/identity-provider/jwt.c
+++ b/src/identity-provider/jwt.c
@@ -33,7 +33,7 @@
 #define JWT_ALG "alg"
 
 /*TODO is this the correct way to define new algs? */
-#define JWT_ALG_VALUE "ED512"
+#define JWT_ALG_VALUE "urn:org:gnunet:jwt:alg:ecdsa:ed25519"
 
 #define JWT_TYP "typ"
 
diff --git a/src/identity-provider/plugin_rest_identity_provider.c 
b/src/identity-provider/plugin_rest_identity_provider.c
index 8011d8da5..326313a13 100644
--- a/src/identity-provider/plugin_rest_identity_provider.c
+++ b/src/identity-provider/plugin_rest_identity_provider.c
@@ -607,6 +607,17 @@ return_response (void *cls)
   cleanup_handle (handle);
 }
 
+static void
+base_64_encode(char *string, char *output)
+{
+  GNUNET_STRINGS_base64_encode(string,strlen(string),&output);
+  char delimiter[] = "=";
+  output = strtok (output, delimiter);
+  while (NULL != output)
+  {
+    output = strtok (NULL, delimiter);
+  }
+}
 
 static void
 collect_finished_cb (void *cls)
@@ -1378,13 +1389,16 @@ oidc_ticket_issue_cb (void* cls,
 //    {
 //      json_object_set_new(object,"nonce",json_string(handle->oidc->nonce));
 //    }
+    //TODO change
     GNUNET_asprintf (&code_json_string, "{\"ticket\":\"%s\"%s%s%s}",
                     ticket_str,
                     (NULL != handle->oidc->nonce) ? ", \"nonce\":\"" : "",
                     (NULL != handle->oidc->nonce) ? handle->oidc->nonce : "",
                     (NULL != handle->oidc->nonce) ? "\"" : "");
     
GNUNET_STRINGS_base64_encode(code_json_string,strlen(code_json_string),&code_base64_final_string);
-
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", code_base64_final_string);
+    base_64_encode(code_json_string, code_base64_final_string);
+    GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "%s\n", code_base64_final_string);
     GNUNET_asprintf (&redirect_uri, "%s?%s=%s&state=%s",
                     handle->oidc->redirect_uri,
                     handle->oidc->response_type,
@@ -1894,21 +1908,22 @@ consume_ticket (void *cls,
 
   if (NULL == identity)
   {
-    GNUNET_SCHEDULER_add_now (&return_response, handle);
+    GNUNET_SCHEDULER_add_now(&cleanup_handle_delayed, handle);
+//    GNUNET_SCHEDULER_add_now (&return_response, handle);
     return;
   }
 
   GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Adding attribute: %s\n",
               attr->name);
-  json_resource = GNUNET_JSONAPI_resource_new 
(GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE,
-                                               attr->name);
-  GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource);
-
-  value = json_string (attr->data);
-  GNUNET_JSONAPI_resource_add_attr (json_resource,
-                                    "value",
-                                    value);
-  json_decref (value);
+//  json_resource = GNUNET_JSONAPI_resource_new 
(GNUNET_REST_JSONAPI_IDENTITY_ATTRIBUTE,
+//                                               attr->name);
+//  GNUNET_JSONAPI_document_resource_add (handle->resp_object, json_resource);
+//
+//  value = json_string (attr->data);
+//  GNUNET_JSONAPI_resource_add_attr (json_resource,
+//                                    "value",
+//                                    value);
+//  json_decref (value);
 }
 
 static void
@@ -1946,9 +1961,9 @@ token_cont(struct GNUNET_REST_RequestHandle *con_handle,
   }
   authorization = GNUNET_CONTAINER_multihashmap_get ( 
handle->rest_handle->header_param_map, &cache_key);
 
+  //TODO authorization pointer will be moved as well
   //split header in "Basic" and [content]
-  credentials = GNUNET_strdup(authorization);
-  credentials = strtok (credentials, delimiter);
+  credentials = strtok (authorization, delimiter);
   if( NULL != credentials)
   {
     credentials = strtok(NULL, delimiter);
@@ -2232,27 +2247,27 @@ token_cont(struct GNUNET_REST_RequestHandle *con_handle,
                   id_token);
 
   resp = GNUNET_REST_create_response (json_error);
-
   MHD_add_response_header (resp, "Cache-Control", "no-store");
   MHD_add_response_header (resp, "Pragma", "no-cache");
   MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
 
-  //necessary? should be
-//  handle->idp_op = 
GNUNET_IDENTITY_PROVIDER_ticket_consume(handle->idp,GNUNET_IDENTITY_ego_get_private_key(handle->ego_entry->ego),ticket,consume_cont,
 handle);
   GNUNET_IDENTITY_ATTRIBUTE_list_destroy(cl);
   //TODO write method
-  handle->resp_object = GNUNET_JSONAPI_document_new ();
   handle->idp = GNUNET_IDENTITY_PROVIDER_connect (cfg);
-  handle->idp_op = 
GNUNET_IDENTITY_PROVIDER_ticket_consume(handle->idp,GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego),ticket,consume_ticket,handle);
+  handle->idp_op = GNUNET_IDENTITY_PROVIDER_ticket_consume (handle->idp,
+                                                           
GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego),
+                                                           ticket,
+                                                           consume_ticket,
+                                                           handle);
   GNUNET_free(access_token_number);
-//  GNUNET_free(credentials);
   GNUNET_free(access_token);
   GNUNET_free(user_psw);
-//  GNUNET_free(code);
+  GNUNET_free(json_error);
+  GNUNET_free(ticket);
+  GNUNET_free(output);
   GNUNET_free(id_token);
   json_decref(root);
-//  GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
 }
 
 /**
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 8e6688b5a..4313f07a2 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -410,14 +410,8 @@ create_response (void *cls,
     {
       MHD_post_process(con_handle->pp, upload_data, *upload_data_size);
     }
-    else
-    {
-      MHD_destroy_post_processor(con_handle->pp);
-    }
-    MHD_get_connection_values (con,
-                               MHD_HEADER_KIND,
-                               &header_iterator,
-                               rest_conndata_handle);
+    MHD_destroy_post_processor(con_handle->pp);
+
     con_handle->state = GN_REST_STATE_PROCESSING;
     con_handle->plugin->process_request (rest_conndata_handle,
                                          &plugin_callback,
@@ -648,7 +642,7 @@ do_accept (void *cls)
                 _("Failed to pass client to MHD\n"));
     return;
   }
-
+  GNUNET_free(s);
   schedule_httpd ();
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]