5

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!!!

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.