philsturgeon/codeigniter-restserver — pull request #304 by davidnewhall (2014-05-14 06:48:44+00:00)
Title: Add method check to access_check and extra data variable for controller use

So I setup my controller as api.php in controllers/ - works fine. I have about 6 methods defined in there for various things like adding and deleting dns records, adding and deleting links (for a resource page), etc. I went to use the access controller but I found that I can only limit access to my 'api' controller - not very useful. I want everyone to be able to update links, but only certain people to update dns. So I added a method column and check. If you set the method to * (the default provided) then it works as before. Checking only the controller. Great, now I can lock down API calls per method. But I only want certain people to update certain dns records (or zones). So I add a preg_match in my controller for the data submitted. But what do I match it against? Data provided by an 'extra' column. This column and its use are completely optional, just like the user_id column in the proposed api keys table (thanks for that by the way!!!). If you add the column and put data in it, the data becomes available to the controller as $this->rest->extra_access. I hope others can find these change useful!