@@ -37,13 +37,21 @@ public function __construct()
3737 $ this ->load ->config ('rest ' );
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
@@ -445,6 +453,55 @@ private function _check_limit($controller_method)
445453
446454 return TRUE ;
447455 }
456+ /*
457+ * Auth override check
458+ *
459+ * Check if there is a specific auth type set for the current class/method being called
460+ */
461+
462+ private function _auth_override_check ()
463+ {
464+
465+ // Assign the class/method auth type override array from the config
466+ $ this ->overrides_array = $ this ->config ->item ('auth_override_class_method ' );
467+
468+ // Check to see if the override array is even populated, otherwise return false
469+ if ( empty ($ this ->overrides_array ) )
470+ {
471+ return false ;
472+ }
473+
474+ // Check to see if there's an override value set for the current class/method being called
475+ if ( empty ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ]) )
476+ {
477+ return false ;
478+ }
479+
480+ // None auth override found, prepare nothing but send back a true override flag
481+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'none ' )
482+ {
483+ return true ;
484+ }
485+
486+ // Basic auth override found, prepare basic
487+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'basic ' )
488+ {
489+ $ this ->_prepare_basic_auth ();
490+ return true ;
491+ }
492+
493+ // Digest auth override found, prepare digest
494+ if ($ this ->overrides_array [$ this ->router ->class ][$ this ->router ->method ] == 'digest ' )
495+ {
496+ $ this ->_prepare_digest_auth ();
497+ return true ;
498+ }
499+
500+ // Return false when there is an override value set but it doesn't match 'basic', 'digest', or 'none'. (the value was misspelled)
501+ return false ;
502+
503+ }
504+
448505
449506 // INPUT FUNCTION --------------------------------------------------------------
450507
0 commit comments