Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on the kind of web service you are inquiring about. Is the web service going to be a daemon for example? or a typical online web service. For either of these you must implement a RESTful type. RESTful meaning a stateless connection. This is where API keys are used; to identity a user for example.</p> <p>Luckily Codeigniter is one with many libraries and extensions. An example of such libraries can be here: <a href="https://github.com/philsturgeon/codeigniter-restserver">https://github.com/philsturgeon/codeigniter-restserver</a></p> <p>Now for security concerns: API keys would replace sessions or any state. You would have to make full checks on the api. Many sites that implement APIs offer different solutions to the same end result.</p> <p>Authentication with API keys are simple. You would check it against a storage type(database).</p> <p>Here is a tutorial using codeigniter and the library linked previously: <a href="http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/">http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/</a></p> <p>This might be somewhat vague, but since you dont have any specific problems or apparent needs its hard to be specific.</p> <p>EDIT: </p> <p>In that case it would be better implementing a RESTful interface so that your iphone app can also use all of the user functionalities that your service provides. The best way would be to make everything accessible in one way. Meaning not having different controllers / models for the iphone connections and web connections. </p> <p>So for example you could have the following controller:</p> <pre><code>&lt;?php class Auth extends CI_Controller{ public function login(){ //Check if their accessing using a RESTful interface; $restful = $this-&gt;rest-&gt;check(); if($restful){ //Check for the API keys; $apiKey = $this-&gt;input-&gt;get('apiKey'); $secretKey = $this-&gt;input-&gt;get('secretKey'); //If you have any rules apon the keys you may check it (i.e. their lengths, //character restrictions, etc...) if(strlen($apiKey) == 10 and strlen($secretKey) == 14) { //Now check against the database if the keys are acceptable; $this-&gt;db-&gt;where('apiKey', $apiKey); $this-&gt;db-&gt;where('secretKey', $secretKey); $this-&gt;db-&gt;limit(1); $query = $this-&gt;db-&gt;get('keys'); if($this-&gt;db-&gt;count_all_results() == 1) { //It's accepted the keys now authenticate the user; foreach ($query-&gt;result() as $row) { $user_id = $row-&gt;user_id; //Now generate a response key; $response_key = $this-&gt;somemodel-&gt;response_key($user_id); //Now return the response key; die(json_encode( array( 'response_key' =&gt; $response_key, 'user_id' =&gt; $user_id ) ) ); } //End of Foreach }//End of Result Count }//End of length / character check; } else { //Perform your usual session login here...; } } } ?&gt; </code></pre> <p>Now this is just a small example for performing these types of requests. This could apply to any type of controller. Though there are a few options here. You could make every request pass the apikey, and the secret each time and verify it at each request. Or you could have some sort of whitelist that once you have been verified the first time each request after that would be whitelisted, and or black listed on the opposite.</p> <p>Hope this helps, Daniel</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload