January 21st, 2009
Posted by Fred Wu
Latest release: v1.2.3
Initially I was going to wait for my Layerful Framework (a transparent layering framework for Kohana) to mature before releasing its bundled modules. However, since this Authlite module can be used independently to Layerful, I am releasing it now.
What is Authlite
Authlite is a user authentication module for Kohana.
What’s the difference between Authlite and Auth?
Kohana comes with an official Auth module which does exactly what was described in the last paragraph, so why another module then?
It is because Authlite offers greater flexibilty. Please read the features outlined below to find more.
Features
- Legacy database compatibility
- Configurable database columns
- Multiple instances of Authlite
- Does not enforce user roles
- Auth-like syntax and usage
- Lightweight
Thanks for this!
It will be very useful to have a tutorial on a *complete* auth system (registration, management, groups and so on…) created with your module. Anyway, thanks for the job :)
Nice module Fred – very flexible especially the non-requirement of hashes.
Any news on when your Layerful framework will be released? Either on Github or complete download? It looks interesting, however your screencast only shows Kohana integration and no Zend integration?
Many thanks for your Great Job.
Keep up da good work.
Cheers
Auth is too complicated for a beginner but so is Authlite. I’m not complaining. Just saying.
Can you believe that I actually found it easier to right my own? Of course, my code must suck as I know little of php and Kohana, but still… I so wish there were more detailed instructions for your code.
Thanks fred this is much better than the normal Kohana Auth.
@Alexander. It’s of course easier to create your own auth if you don’t know Kohana Auth but once you’re used to it, you’d find it hard not to use.
Search the Kohana forums and you’ll find a LOT of questions being answered there. Your questions might have already been answered.
I love this module! Extremely lightweight and dead simple to implement. I’ve used Kohana’s Auth module for a few sites but I like this much better. Thanks.
Is this module compatible with Kohana 2.3.4 reply me soon
Hi Fred. I’m this close to getting this module to work but I’m running into a snag. I’m familiar with PHP but new to Kohana, so it could very well be something I’m doing but I can’t see it.
I’m getting the login to work correctly. It’s hitting the database (verified the query in the Profiler) and redirecting to my Admin controller’s index action successfully but it’s not setting the session variable. So, when I check $this->authlite->logged_in(), it’s returning false. Would you – or anyone else here – be able to point out something I’m missing?
class Admin_Controller extends Website_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$this->profiler = new Profiler;
$this->session = Session::instance(); // added in case it would make a difference. it did not.
$this->authlite = Authlite::instance('authlite');
if (!$this->authlite->logged_in()) {
//url::redirect(Router::$controller.'/login');
echo "not logged in";
} else {
/*$this->user = $this->authlite->get_user();
echo $this->user;*/
echo "logged in";
}
}
public function login() {
$this->profiler = new Profiler;
$this->authlite = Authlite::instance('authlite');
if ($this->authlite->logged_in()) {
url::redirect('admin');
} else {
if ($_POST) {
$login = $this->authlite->login($_POST['username'], $_POST['password']);
if ($login == true) {
url::redirect(Router::$controller);
} else {
echo 'login failed.';
}
}
}
}
}
This is just a small personal website I’m working on to get familiar with Kohana, which is one reason I wanted to use this module. I don’t need anything fancy like roles and such. Just a way to make sure I’m the only one who can get to the admin pages. Thanks for any help you can provide.
-michael
Will there be a KO3 version (soon)?
Thanks
Yes Authlite will be updated to work with K3 very soon. :-)
Hey Fred,
Great module! It certainly makes authorisation nice and easy.
I’ve modded the module a little, more to my purposes, and am about to make another change, but thought I’d see if you had any thoughts.
At the moment, logged_in() returns an ORM instance, but for example, I’m using a user model, and actually I want to return an instance, so throughout the rest of the models in my application I can do something like…
User_Model::instance()->some_property;
…without having to pass the only logged-in user into all my app’s models.
Have you ever had any thoughts this way?
I’ll probably just extend the class, but it might be a nice addition into the core.
Cheers,
Dave
Hi!
Is it possible to have multiple clients logged in as the same user simultaneously? Will there be trouble with sessions and stuff if so?
Thanks. Great module!
Hi,
thanks for your great Module.
Do you have a tutorial or examples, how to use this Module?
I am a beginner at the kohana framework and the standard Auth Module is not enough documented….
Thanks
Greets, Alex
Please can some help with a simple tutorial/or instruction on how to set this up
Hey Dave … i’ve solution
(my english so bad)
so…
File: modules/authlite/classes/authlite.php
line: 226
code:
if ($user->loaded)
change for:
if ($user->loaded())
— it’s all!
Thanks Michael, i started with this framework
Good luck!