CodeIgniter Forums
how implement library rest with authentication - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: how implement library rest with authentication (/showthread.php?tid=64840)



how implement library rest with authentication - scasabonne - 03-31-2016

Hi,
how i implement authentication with rest (REST_CONTROLLER LIBRARY) and jquery but in global way and not for each petition

jquery
PHP Code:
$config['rest_valid_logins'] = array("admin"=>"1234");$.ajaxSetup({
    xhrFields: {
        withCredentialstrue
    
},
    beforeSend: function (xhr) {
        xhr.setRequestHeader('Authorization''Basic ' btoa('admin:1234'));
    }
}); 

rest
PHP Code:
$config['auth_source'] = 'basic';
$config['rest_valid_logins'] = array("admin"=>"1234"); 


regards


RE: how implement library rest with authentication - Tpojka - 04-03-2016

Storing plain passwords in javascript file is big no-no and unacceptable.
What ever is up to passwords it mustn't be tied with javascript.
Considering CI and REST, have you checked this tutorial?