svn commit: samba r19138 - in branches/SAMBA_4_0/jsonrpc: . qooxdoo
derrell at samba.org
derrell at samba.org
Fri Oct 6 15:36:07 GMT 2006
Author: derrell
Date: 2006-10-06 15:36:07 +0000 (Fri, 06 Oct 2006)
New Revision: 19138
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=19138
Log:
add authentication capability; fix typos
Added:
branches/SAMBA_4_0/jsonrpc/json_auth.esp
Modified:
branches/SAMBA_4_0/jsonrpc/json.esp
branches/SAMBA_4_0/jsonrpc/jsondate.esp
branches/SAMBA_4_0/jsonrpc/qooxdoo/test.esp
branches/SAMBA_4_0/jsonrpc/request.esp
Changeset:
Modified: branches/SAMBA_4_0/jsonrpc/json.esp
===================================================================
--- branches/SAMBA_4_0/jsonrpc/json.esp 2006-10-06 15:17:02 UTC (rev 19137)
+++ branches/SAMBA_4_0/jsonrpc/json.esp 2006-10-06 15:36:07 UTC (rev 19138)
@@ -260,4 +260,10 @@
}
testParse();
*/
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
%>
Added: branches/SAMBA_4_0/jsonrpc/json_auth.esp
===================================================================
--- branches/SAMBA_4_0/jsonrpc/json_auth.esp 2006-10-06 15:17:02 UTC (rev 19137)
+++ branches/SAMBA_4_0/jsonrpc/json_auth.esp 2006-10-06 15:36:07 UTC (rev 19138)
@@ -0,0 +1,13 @@
+<%
+/* Return true to allow access; false otherwise */
+function json_authenticate(serviceComponents, method)
+{
+ return true;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+%>
Modified: branches/SAMBA_4_0/jsonrpc/jsondate.esp
===================================================================
--- branches/SAMBA_4_0/jsonrpc/jsondate.esp 2006-10-06 15:17:02 UTC (rev 19137)
+++ branches/SAMBA_4_0/jsonrpc/jsondate.esp 2006-10-06 15:36:07 UTC (rev 19138)
@@ -1,4 +1,4 @@
-
+<%
/*
* Copyright:
* (C) 2006 by Derrell Lipman
@@ -190,3 +190,11 @@
JSON_Date = new Object();
JSON_Date.create = _JSON_Date_create;
_JSON_Date_create = null;
+
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+%>
Modified: branches/SAMBA_4_0/jsonrpc/qooxdoo/test.esp
===================================================================
--- branches/SAMBA_4_0/jsonrpc/qooxdoo/test.esp 2006-10-06 15:17:02 UTC (rev 19137)
+++ branches/SAMBA_4_0/jsonrpc/qooxdoo/test.esp 2006-10-06 15:36:07 UTC (rev 19138)
@@ -227,4 +227,10 @@
}
jsonrpc.method.getError = _getError;
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
%>
Modified: branches/SAMBA_4_0/jsonrpc/request.esp
===================================================================
--- branches/SAMBA_4_0/jsonrpc/request.esp 2006-10-06 15:17:02 UTC (rev 19137)
+++ branches/SAMBA_4_0/jsonrpc/request.esp 2006-10-06 15:36:07 UTC (rev 19138)
@@ -19,6 +19,10 @@
/* Bring in the date class */
jsonrpc_include("jsondate.esp");
+/* Load the authentication script */
+jsonrpc_include("json_auth.esp");
+
+
/* bring the string functions into the global frame */
string_init(global);
@@ -165,26 +169,31 @@
return false;
}
- if (req.id == undefined)
+ if (typeof(req) != "object")
{
return false;
}
- if (req.service == undefined)
+ if (req["id"] == undefined)
{
return false;
}
- if (req.method == undefined)
+ if (req["service"] == undefined)
{
return false;
}
- if (req.params == undefined)
+ if (req["method"] == undefined)
{
return false;
}
+ if (req["params"] == undefined)
+ {
+ return false;
+ }
+
return true;
}
jsonrpc.validRequest = _jsonValidRequest;
@@ -411,7 +420,7 @@
* The following completely unreasonable sequence of commands is because:
*
* (a) ejs evaluates all OR'ed expressions even if an early one is false, and
- * bars on the typeof(method) call if method is undefined
+ * barfs on the typeof(method) call if method is undefined
*
* (b) ejs does not allow comparing against the string "function"!!! What
* the hell is special about that particular string???
@@ -437,6 +446,15 @@
return;
}
+/* Ensure the logged-in user is allowed to issue the requested method */
+if (! json_authenticate(serviceComponents, method))
+{
+ error.setError(jsonrpc.Constant.ErrorCode.PermissionDenied,
+ "Permission denied");
+ error.Send();
+ return;
+}
+
/* Most errors from here on out will be Application-generated */
error.setOrigin(jsonrpc.Constant.ErrorOrigin.Application);
@@ -456,4 +474,10 @@
ret.result = retval;
ret.id = jsonInput.id;
sendReply(Json.encode(ret), scriptTransportId);
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
%>
More information about the samba-cvs
mailing list