php - Kohana authenticate user with token

332

Ive accomplished this with Spring framework, however now I am tasked with this same functionality but in Kohana PHP. Looking to protect a site by implementing some authentication and session. When the user accesses this system they will pass a token with the request through the URL. This token will be read and it will make a web service call to ensure its valid. If its valid they will be redirected to the application. If not it will direct them to error page.

Can anyone direct me to samples for this type of functionality? I looked at the AUTH module for kohana, but I dont think thats what I am looking for.

Okay so maybe I get some token from the url and store it in a session parameter

public function before(){
      parent::before();
    session_start();

    if(!isset($_SESSION['token'])){
         $_token = $_SESSION['token'] = $this->request->query('token'); 
      }

    echo $_SESSION['token'];

   // echo isset($session->get('token'));
   if(isset($_SESSION['token'])){
      $view = View::factory('home/index');
      $this->template->content = $view;
      $this->_post = $this->request->post();
   } else {
    echo 'inside else';
       header('HTTP/1.0 403 Forbidden');
       $this->request->headers['HTTP/1.1'] = '403';
       die('You are not allowed to access this file.');     
  }


}
436

Answer

Solution:

You can look at method autologin , this is similar to your realization, auth by token

People are also looking for solutions to the problem: php - How to count records in sql database?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.