![]() |
Phil Surgeon REST server library and how to work with keys for some requests only - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Phil Surgeon REST server library and how to work with keys for some requests only (/showthread.php?tid=43906) |
Phil Surgeon REST server library and how to work with keys for some requests only - El Forum - 07-27-2011 [eluser]Madoc[/eluser] Hello, I am currently working with Phil Sturgeon's REST server library and I got as far as handling requests and responses using the very useful "key" system for security. Now I need to be able to handle some of the requests as public and some with the key protection. I can not find my way around doing that. The key configuration settings are given on the rest.php config file of the library: Code: $config['rest_enable_keys'] = TRUE; But I can not get my head around bypassing this for certain requests (i.e controller/method). I tried to use the means available on the auth types: Code: $config['auth_override_class_method']['server']['persons'] = 'none'; but this did not work as I am guessing that the key system has nothing to do with http authentication. Anyone have any idea ? Phil Surgeon REST server library and how to work with keys for some requests only - El Forum - 07-28-2011 [eluser]Madoc[/eluser] Ok as nobody seemed to be able to help I managed to modify the REST server library a bit to bypass to key system for specified methods. Here is how I did it. On the REST_Controller.php class, modify the if statement on line 129 to: Code: // Checking for keys? GET TO WORK! and add the following config variable to the rest.php config file: Code: /* Now there is probably a better way of doing this but it is working fine for me so far. What this does is allow you to specify which methods you want to keep public (i.e no key required on the http request). NB: the name of the method should not include the type of request at the end as required by the library. For instance, if you have a "person" method on a "server" controller: Code: public function person_put() then the config variable would look like Code: $config['key_override'] = array ('server/person'); this means that the key system will be bypassed for every type of "person" request. I hope this makes sense ! |