summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/rest.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-06-01 22:40:22 -0700
committerBharat Mediratta <bharat@menalto.com>2009-06-01 22:40:22 -0700
commit43abcd93867996e32890fa101ae09255ccc24847 (patch)
tree67ddd78724ff7c7f9a369564cf0e8853e1d74374 /modules/gallery/controllers/rest.php
parentb9af090cbd9ed7d6470e3852bc35ee0cebeaf9bf (diff)
Security pass over all controller code. Mostly adding CSRF checking
and verifying user permissions, but there are several above-the-bar changes: 1) Server add is now only available to admins. This is a hard requirement because we have to limit server access (eg: server_add::children) to a user subset and the current permission model doesn't include that. Easiest fix is to restrict to admins. Got rid of the server_add permission. 2) We now know check permissions at every level, which means in controllers AND in helpers. This "belt and suspenders" approach will give us defense in depth in case we overlook it in one area. 3) We now do CSRF checking in every controller method that changes the code, in addition to the Forge auto-check. Again, defense in depth and it makes scanning the code for security much simpler. 4) Moved Simple_Uploader_Controller::convert_filename_to_title to item:convert_filename_to_title 5) Fixed a bug in sending notification emails. 6) Fixed the Organize code to verify that you only have access to your own tasks. In general, added permission checks to organize which had pretty much no validation code. I did my best to verify every feature that I touched.
Diffstat (limited to 'modules/gallery/controllers/rest.php')
-rw-r--r--modules/gallery/controllers/rest.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/gallery/controllers/rest.php b/modules/gallery/controllers/rest.php
index 11a6bbac..2edf079f 100644
--- a/modules/gallery/controllers/rest.php
+++ b/modules/gallery/controllers/rest.php
@@ -86,21 +86,20 @@ class REST_Controller extends Controller {
return Kohana::show_404();
}
- if ($request_method != "get") {
- access::verify_csrf();
- }
-
switch ($request_method) {
case "get":
return $this->_show($resource);
case "put":
+ access::verify_csrf();
return $this->_update($resource);
case "delete":
+ access::verify_csrf();
return $this->_delete($resource);
case "post":
+ access::verify_csrf();
return $this->_create($resource);
}
}
@@ -111,17 +110,18 @@ class REST_Controller extends Controller {
throw new Exception("@todo ERROR_MISSING_RESOURCE_TYPE");
}
- // @todo this needs security checks
$resource = ORM::factory($this->resource_type, $resource_id);
if (!$resource->loaded) {
return Kohana::show_404();
}
+ // Security checks must be performed in _form_edit
return $this->_form_edit($resource);
}
/* We're adding a new item, pass along any additional parameters. */
public function form_add($parameters) {
+ // Security checks must be performed in _form_add
return $this->_form_add($parameters);
}