user2524908
user2524908

Reputation: 871

Kohana authenticate user with token

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.');     
  }


}

Upvotes: 0

Views: 435

Answers (1)

MisterX
MisterX

Reputation: 310

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

Upvotes: 0

Related Questions