codeigniter-restserver icon indicating copy to clipboard operation
codeigniter-restserver copied to clipboard

Add auth_override_class_method for REST Keys

Open boh1996 opened this issue 13 years ago • 3 comments

Make it possible to disable or enable the REST Keys, like with digest and basic auth. Because i have some endpoints where i don't want rest key auth and some of the i want to have it.

boh1996 avatar Feb 27 '13 19:02 boh1996

Is this possible? It doesn't appear to be working for me...

mrchimp avatar Sep 04 '14 13:09 mrchimp

You may be able to achieve this by setting different auth methods on different endpoints.....

rest.php

/*
|--------------------------------------------------------------------------
| Override auth types for specific class/method
|--------------------------------------------------------------------------
|
| Set specific authentication types for methods within a class (controller)
|
| Set as many config entries as needed.  Any methods not set will use the default 'rest_auth' config value.
|
| example:
|
|           $config['auth_override_class_method']['deals']['view'] = 'none';
|           $config['auth_override_class_method']['deals']['insert'] = 'digest';
|           $config['auth_override_class_method']['accounts']['user'] = 'basic';
|           $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic';
|
| Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name)
| Acceptable values are; 'none', 'digest' and 'basic'.
|
*/
// $config['auth_override_class_method']['deals']['view'] = 'none';
// $config['auth_override_class_method']['deals']['insert'] = 'digest';
// $config['auth_override_class_method']['accounts']['user'] = 'basic';
// $config['auth_override_class_method']['dashboard']['*'] = 'basic';

GaryRogers avatar Sep 04 '14 17:09 GaryRogers

I actually tried that before I asked. Turns out we had HTTP auth enabled on our dev server which I was interpreting as the REST auth failing! Thanks for the response! For anyone else wondering, the above totally works.

mrchimp avatar Sep 05 '14 10:09 mrchimp