I’d like to build a stateless system with Kohana, so I don’t want to use sessions. I’d like to send a username and password with every request (how those credentials are transferred is irrelevant at this point), check that the credentials are correct with Kohana, and respond with the relevant data or a 401.
I understand I’ll probably need to extend the Auth module, but for some reason I keep getting 500s. Here’s what I’m trying:
classes/Auth.php
<?php defined('SYSPATH') OR die('No direct access allowed');
class Auth extends Kohana_Auth {
public static function checkCredentials($username, $password) {
return TRUE;
}
public function password($username) {
parent::password($username);
}
public function check_password($password) {
parent::check_password($password);
}
protected function _login($username, $password) {
parent::_login($username, $password);
}
}
classes/Controller/Frontdesk.php
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Controller_Frontdesk extends Kohana_Controller {
public function before() {
parent::before();
// If not logged in, throw exception
if (!Auth::checkCredentials('[email protected]','fido')) throw new HTTP_Exception_401();
}
}
_login()needed to be compatible with the method it was overriding. I was missing a parameter. - Jezen Thomas