@@ -37,13 +37,21 @@ public function __construct()
3737 $ this ->request ->method = $ this ->_detect_method ();
3838
3939 $ this ->load ->library ('security ' );
40- if ($ this ->config ->item ('rest_auth ' ) == 'basic ' )
41- {
42- $ this ->_prepare_basic_auth ();
43- }
44- elseif ($ this ->config ->item ('rest_auth ' ) == 'digest ' )
45- {
46- $ this ->_prepare_digest_auth ();
40+
41+ // Check if there is a specific auth type for the current class/method
42+ $ this ->auth_override = $ this ->_auth_override_check ();
43+
44+ // When there is no specific override for the current class/method, use the default auth value set in the config
45+ if ( $ this ->auth_override !== TRUE )
46+ {
47+ if ($ this ->config ->item ('rest_auth ' ) == 'basic ' )
48+ {
49+ $ this ->_prepare_basic_auth ();
50+ }
51+ elseif ($ this ->config ->item ('rest_auth ' ) == 'digest ' )
52+ {
53+ $ this ->_prepare_digest_auth ();
54+ }
4755 }
4856
4957 // Some Methods cant have a body
@@ -455,6 +463,55 @@ private function _check_limit($controller_method)
455463
456464 return TRUE ;
457465 }
466+ /*
467+ * Auth override check
468+ *
469+ * Check if there is a specific auth type set for the current class/method being called
470+ */
471+
472+ private function _auth_override_check ()
473+ {
474+
475+ // Assign the class/method auth type override array from the config
476+ $ this ->overrides_array = $ this ->config ->item ('auth_override_class_method ' );
477+
478+ // Check to see if the override array is even populated, otherwise return false
479+ if ( empty ($ this ->overrides_array ) )
480+ {
481+ return false ;
482+ }
483+
484+ // Check to see if there's an override value set for the current class/method being called
485+ if ( empty ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ]) )
486+ {
487+ return false ;
488+ }
489+
490+ // None auth override found, prepare nothing but send back a true override flag
491+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'none ' )
492+ {
493+ return true ;
494+ }
495+
496+ // Basic auth override found, prepare basic
497+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'basic ' )
498+ {
499+ $ this ->_prepare_basic_auth ();
500+ return true ;
501+ }
502+
503+ // Digest auth override found, prepare digest
504+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'digest ' )
505+ {
506+ $ this ->_prepare_digest_auth ();
507+ return true ;
508+ }
509+
510+ // Return false when there is an override value set but it doesn't match 'basic', 'digest', or 'none'. (the value was misspelled)
511+ return false ;
512+
513+ }
514+
458515
459516 // INPUT FUNCTION --------------------------------------------------------------
460517
0 commit comments