Question

I have uncomment in module loader to load auth, but what I am not understanding is that how to tell auth module that which fields of which table it should use to authenticate? I also didn't find that in userguide in Kohana 3 as I found that userguide for auth module is not present.

So please tell if some one is already using it. And if it use some default fields of some table then how can I modify it?

thanks for reading my question and your effort to answer it.

Was it helpful?

Solution

Here are the steps for you

  • Uncomment the Auth module in bootstrap.php (you have done it already)
  • in ORM Module, yes in ORM Module you will find auth-schema-mysql.sql & auth-schema-postgresql.sql. Use the one you needed.
  • configure the config file auth.php as needed. Below is the configuration I am using.

    <?php defined('SYSPATH') or die('No direct access allowed.');
    return array(
        'driver'       => 'ORM',
        'hash_method'  => 'sha256',
        'hash_key'     => "ica_hash_key",
        'lifetime'     => Date::MINUTE * 30,
        'session_type' => 'database',
        'session_key'  => 'auth_user',
    );
    
  • set Cookie::$salt in bootstrap.php. Add this line in your bootstrap.php.

    Cookie::$salt = 'YourSecretCookieSalt';
    
  • you are done with Auth module configuration ;)


As you have configured auth module, obviously you have executed the sql script. You will get users, roles, roles_users & users_tokens table created in your database.

Now you can change users table with adding more column. As you are using ORM, Model_User is already there for you which is an ORM :)

So this should be all, i believe.

OTHER TIPS

Both the MySQL and PostGreSQL database schemas for the Auth ORM driver can be found in the ORM module. But make sure the length of the password field is the correct one for your choosen hashing algorithm. For the default sha256 it should be 64, for sha512 is should be 128, for md5 is should be 32 and for sha1 it should be 40 etc.

I guess you could overload the __get() and __set() methods if you really want to change the table fields. Or you could create a database view but that could give problems with insert and update queries. Or try out Wouter's A1 module which does let you change the column names it uses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top