FSN#39957 API2 bestand tegen CSRF misbruik
svn path=/Website/trunk/; revision=33222
This commit is contained in:
@@ -25,6 +25,7 @@ var fac_id = Request.QueryString("fac_id").Count > 0&&String(Request.QueryString
|
||||
$(doInit);
|
||||
$(doBuild);
|
||||
});
|
||||
var RVT_token = "<%=safe.jsstring(protectRequest.theToken())%>";
|
||||
</script>
|
||||
<style>
|
||||
pre { font-size: 1.2em;
|
||||
@@ -52,7 +53,8 @@ var fac_id = Request.QueryString("fac_id").Count > 0&&String(Request.QueryString
|
||||
</tr>
|
||||
<tr><td><label>APIKEY</label></td>
|
||||
<td><input id="apikey" type="text" style="width:250px" value="APIPFO">
|
||||
<% if (user_key > 0) { %>
|
||||
<%
|
||||
if (user_key > 0) { %>
|
||||
Herkend als: <%= safe.html(user.oslogin()) %>
|
||||
<% } %>
|
||||
</td>
|
||||
|
||||
@@ -40,7 +40,9 @@ function doSubmit()
|
||||
tm = new Date;
|
||||
$.ajax(url, { type: method,
|
||||
data: data,
|
||||
headers: { "X-FACILITOR-API-Key": apikey }
|
||||
headers: { "X-FACILITOR-API-Key": apikey,
|
||||
"X-CSRF-TOKEN": RVT_token
|
||||
}
|
||||
// dan werkt de header niet dataType: "jsonp"
|
||||
}
|
||||
).done(callbackDone).fail(callbackFail);
|
||||
|
||||
@@ -26,6 +26,14 @@ api2_rest = {
|
||||
if (!APIKEY && Session("user_key") > 0)
|
||||
{
|
||||
user_key = Session("user_key"); // Hierdoor is de API intern te gebruiken zonder authenticatie
|
||||
var method = String(Request.ServerVariables("REQUEST_METHOD"));
|
||||
if (method != "GET") // Vereis dan wel het CSRF token
|
||||
{
|
||||
var token = Request.ServerVariables("HTTP_X_CSRF_TOKEN").Count // Meegegeven als X-CSRF-TOKEN
|
||||
? String(Request.ServerVariables("HTTP_X_CSRF_TOKEN"))
|
||||
: "";
|
||||
protectRequest.validateToken(token);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user