0

I am having trouble with authentication in codeigniter-restserver.

When I set the config: $config['rest_auth'] to either basic or digest, I can't seem to get through the validation, using the standard logins.

Is there anything else I need to take into account?

tereško
  • 58,060
  • 25
  • 98
  • 150

2 Answers2

0

I think you must populate the allowed username and passwords in /application/config/rest.php :

$config['rest_valid_logins'] = array('user1' => 'password');
MaxiWheat
  • 6,133
  • 6
  • 47
  • 76
0

For basic, to work you need rest_auth to basic in your /application/config/rest.php

$config['rest_auth'] = 'basic';

then set username and password in the same file, to do this go to rest_valid_logins configuration in your /application/config/rest.php and set the key as the username and set the password as the value for that key. Remember it's an associate array so you can use multiple value key pairs.

$config['rest_valid_logins'] = ['admin' => '1234'];

Then make a call using HTTP basic authentication. To do that use the following format: https://username:password@domain/path/to/api

For example, it could be https://admin:1234@localhost/api/users

Kunwar
  • 127
  • 7