title: CodeIgniter 2.2.0 + ION_Auth + Restful API
body: <p>I'm using code igniter 2.2.0 with ion_auth library to authenticate my users but now I need to create some restful services and i want to use <a href="https://github.com/chriskacerguis/codeigniter-restserver" rel="nofollow">this</a> library. I saw that in rest.php I can change the rest_auth parameter to 'digest' and that I can define the auth_source as a 'library', the problem is that I don't know if I can set ion_auth library as authentication library.</p>
  
  <p>1- On my /application/confing/rest.php file I set those prefs:</p>
  
  <pre><code>$config['rest_auth'] = 'digest';
  $config['auth_source'] = 'library';
  $config['auth_library_class'] = 'ion_auth';
  $config['auth_library_function'] = 'get_hashed_password';
  $config['rest_enable_keys'] = TRUE;
  </code></pre>
  
  <p>2- I created a new function on /application/libraries/ion_auth</p>
  
  <pre><code>public function get_hashed_password($username) {
      $user = $this-&gt;db-&gt;select('password')-&gt;where('email',$username)-&gt;get('users');
      if ($user-&gt;num_rows() == 0) {
          return false;
      }
      $user_details = $user-&gt;row();
      $HA1 = $user_details-&gt;password;
      return $HA1;
  }
  </code></pre>
  
  <p>Then I tried to connect to my example service but the answer was:</p>
  
  <pre><code>{"status":0,"error":"Invalid credentials"}
  </code></pre>
  
  <p>I tried to do some debug on my server and I think that the problem is that the get_hashed_password() function should return the password using md5 and if I get the password directly from the database ion_auth is using bcrypt. I think that this is the reason why the digest['response'] and the valid_response variables from REST_controller in line number 1411 are not equal.</p>
  
  <p>I also tried to force REST_crontroller to accept the credentials (I know that it's not correct but I was doing some tests) then my problem is that I'm always getting the following error:</p>
  
  <pre><code>{"status":false,"error":"Invalid API Key "}
  </code></pre>
  
  <p>Anyone knows how to make It work?</p>
  
  <p>Thanks for your help!</p>