5 Sometimes the best way to learn is to jump right in and read the code from another module. The [ORM](https://github.com/kohana/orm/blob/3.2/develop/classes/kohana/auth/orm.php) module comes with an auth driver you can learn from.
7 [!!] We will be developing an `example` driver. In your own driver you will substitute `example` with your driver name.
9 This example file would be saved at `APPPATH/classes/auth/example.php` (or `MODPATH` if you are creating a module).
15 First we will show you a quick example and then break down what is going on.
18 class Auth_Example extends Auth
20 protected function _login($username, $password, $remember)
22 // Do username/password check here
25 public function password($username)
27 // Return the password for the username
30 public function check_password($password)
32 // Check to see if the logged in user has the given password
35 public function logged_in($role = NULL)
37 // Check to see if the user is logged in, and if $role is set, has all roles
40 public function get_user($default = NULL)
42 // Get the logged in user, or return the $default if a user is not found
49 All drivers must extend the [Auth] class.
51 class Auth_Example extends Auth
55 The `Auth` class has 3 abstract methods that must be defined in your new driver.
58 abstract protected function _login($username, $password, $remember);
60 abstract public function password($username);
62 abstract public function check_password($user);
65 ## Extending Functionality
67 Given that every auth system is going to check if users exist and if they have roles or not you will more than likely have to change some default functionality.
69 Here are a few functions that you should pay attention to.
72 public function logged_in($role = NULL)
74 public function get_user($default = NULL)
77 ## Activating the Driver
79 After you create your driver you will want to use it. It is a easy as setting the `driver` [configuration](config) option to the name of your driver (in our case `example`).