From b965b8cc10f094ec0408d57b1bc9aeee0bca501c Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Tue, 27 May 2014 14:40:58 +0200 Subject: ubus: add CORS header support In order to support cross-domain AJAX requests to the /ubus endpoint we need to implement the Cross-Origin Resource Sharing (CORS) spec in the ubus plugin. - Implement a new option "-X" to enable CORS support in ubus - Implement rudimentary support for "OPTIONS" HTTP requests - Implement essential CORS headers the ubus plugin The current CORS response headers merely reflect the request headers sent by the client, this way any requesting origin is automatically allowed. Cross-domain cookies (Access-Control-Allow-Credentials) are unconditionally enabled. Restricting permitted origins and toggle the credential accepting can be made configurable in a future commit to allow more fine grained control over permitted AJAX clients. Signed-off-by: Jo-Philipp Wich --- uhttpd.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'uhttpd.h') diff --git a/uhttpd.h b/uhttpd.h index daf68ce..6ef28d9 100644 --- a/uhttpd.h +++ b/uhttpd.h @@ -68,6 +68,7 @@ struct config { int http_keepalive; int script_timeout; int ubus_noauth; + int ubus_cors; }; struct auth_realm { @@ -81,6 +82,7 @@ enum http_method { UH_HTTP_MSG_GET, UH_HTTP_MSG_POST, UH_HTTP_MSG_HEAD, + UH_HTTP_MSG_OPTIONS, }; enum http_version { -- cgit v1.2.3