Hello i am having a problemm to understand how to enable basic authentication using CodeIgniter and using the https://github.com/chriskacerguis/codeigniter-restserver. The rest.php:
|--------------------------------------------------------------------------
| REST Login
|--------------------------------------------------------------------------
|
| Set to specify the REST API requires to be logged in
|
| FALSE No login required
| 'basic' Unsecure login
| 'digest' More secure login
| 'session' Check for a PHP session variable. See 'auth_source' to set the
| authorization key
|
*/
$config['rest_auth'] = 'basic';
i enable the basic auth and below i have this:
/*
|--------------------------------------------------------------------------
| REST Login Usernames
|--------------------------------------------------------------------------
|
| Array of usernames and passwords for login, if ldap is configured this is ignored
|
*/
$config['rest_valid_logins'] = ['admin' => '1234'];
if i use admin as username and 1234 as password the login is fine. My question is how can i register users to my database and also update the valid logins config? When the user registers i dont have to go to rest.php and add the record to $config['rest_valid_logins'] but it will be done automatically?
Any help will be appreciated!!!
Instead of use the basic login, you can create API keys for your REST server.
Each user created in you platform will need a record in the key's table. Those keys need to be sent in the header of each request.
Please, check the rest.php file. There's the CREATE TABLE statement for the key's table.
You need to change these three settings:
$config['rest_keys_table']
with the name of table.
$config['rest_enable_keys']
with the true value.
$config['rest_key_column']
with the column responsible for storage the key data.
Therefore, each request will be treated by CodeIgniter, who will check if the API key sent in the header is valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With