aboutsummaryrefslogtreecommitdiff
path: root/src/rest
diff options
context:
space:
mode:
authorPhil <phil.buschmann@tum.de>2018-02-26 17:01:24 +0100
committerPhil <phil.buschmann@tum.de>2018-02-26 17:01:24 +0100
commit2363773d8a81d253614fa3892cead6ebab69c246 (patch)
tree9008c0907e1bcb04ad80e85e86d467d8b920af82 /src/rest
parentbbe8e9a4e5bc9b60a5cc5f54385e6252a0487aea (diff)
downloadgnunet-2363773d8a81d253614fa3892cead6ebab69c246.tar.gz
gnunet-2363773d8a81d253614fa3892cead6ebab69c246.zip
-token endpoint fix wip
Diffstat (limited to 'src/rest')
-rw-r--r--src/rest/gnunet-rest-server.c25
-rw-r--r--src/rest/rest.conf1
2 files changed, 24 insertions, 2 deletions
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index fdcd4f9c5..2f840be8b 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -119,6 +119,11 @@ static char* allow_origin;
119static char* allow_headers; 119static char* allow_headers;
120 120
121/** 121/**
122 * Allowed Credentials (CORS)
123 */
124static char* allow_credentials;
125
126/**
122 * MHD Connection handle 127 * MHD Connection handle
123 */ 128 */
124struct MhdConnectionHandle 129struct MhdConnectionHandle
@@ -301,7 +306,7 @@ post_data_iter (void *cls,
301 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) 306 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
302 { 307 {
303 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 308 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
304 "Could not load add url param `%s'=%s\n", 309 "Could not load add url param '%s'=%s\n",
305 key, data); 310 key, data);
306 GNUNET_free(val); 311 GNUNET_free(val);
307 } 312 }
@@ -404,7 +409,7 @@ create_response (void *cls,
404 &header_iterator, 409 &header_iterator,
405 rest_conndata_handle); 410 rest_conndata_handle);
406 con_handle->pp = MHD_create_post_processor(con, 411 con_handle->pp = MHD_create_post_processor(con,
407 4000, 412 65536,
408 post_data_iter, 413 post_data_iter,
409 rest_conndata_handle); 414 rest_conndata_handle);
410 if (*upload_data_size) 415 if (*upload_data_size)
@@ -430,6 +435,12 @@ create_response (void *cls,
430 MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, 435 MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
431 allow_origin); 436 allow_origin);
432 } 437 }
438 if (NULL != allow_credentials)
439 {
440 MHD_add_response_header (con_handle->response,
441 "Access-Control-Allow-Credentials",
442 allow_credentials);
443 }
433 if (NULL != allow_headers) 444 if (NULL != allow_headers)
434 { 445 {
435 MHD_add_response_header (con_handle->response, 446 MHD_add_response_header (con_handle->response,
@@ -660,6 +671,7 @@ do_shutdown (void *cls)
660 "Shutting down...\n"); 671 "Shutting down...\n");
661 kill_httpd (); 672 kill_httpd ();
662 GNUNET_free_non_null (allow_origin); 673 GNUNET_free_non_null (allow_origin);
674 GNUNET_free_non_null (allow_credentials);
663 GNUNET_free_non_null (allow_headers); 675 GNUNET_free_non_null (allow_headers);
664} 676}
665 677
@@ -804,6 +816,15 @@ run (void *cls,
804 } 816 }
805 817
806 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "rest", 818 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "rest",
819 "REST_ALLOW_CREDENTIALS",
820 &allow_credentials))
821 {
822 //No origin specified
823 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
824 "No CORS Access-Control-Allow-Origin Header will be sent...\n");
825 }
826
827 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "rest",
807 "REST_ALLOW_HEADERS", 828 "REST_ALLOW_HEADERS",
808 &allow_headers)) 829 &allow_headers))
809 { 830 {
diff --git a/src/rest/rest.conf b/src/rest/rest.conf
index f74d772e8..0a919df20 100644
--- a/src/rest/rest.conf
+++ b/src/rest/rest.conf
@@ -4,3 +4,4 @@ BINARY=gnunet-rest-server
4REST_PORT=7776 4REST_PORT=7776
5REST_ALLOW_HEADERS=Authorization,Accept,Content-Type 5REST_ALLOW_HEADERS=Authorization,Accept,Content-Type
6REST_ALLOW_ORIGIN=http://localhost:8000 6REST_ALLOW_ORIGIN=http://localhost:8000
7REST_ALLOW_CREDENTIALS=true \ No newline at end of file