User Guide | Installation Guide

Setting up flexi auth is a quick and painless process that can be completed in just a few minutes.

Installing flexi auth

The following notes describe how to install flexi auth to a brand new Codeigniter 2.0 installation.

The guide includes the steps to install either the 'library only' or 'demo' versions of flexi auth.
The library version contains only the essential files required to run flexi auth, the demo version includes all files to run an installation of the online flexi auth demo.

Note that some of the steps listed below may not need to be completed if the flexi auth library is being installed to to a previously setup CodeIgniter installation.


Update the 'config/config.php' file

The following steps may not need to be applied to a previous CodeIgniter installation.

  • Update the 'base_url' to CodeIgniters root installation directory.
    $config['base_url'] = 'http://localhost/your_codeigniter_directory/';
  • Update the 'index_page' config setting to ''. This will remove 'index.php' from the sites urls.
    Note that this is optional, and if done, a '.htaccess' files needs to be included in the root directory of the installation.
    A sample '.htaccess' file is included in the demo.
    $config['index_page'] = '';
  • Update the 'encryption_key' config setting to a value of your choice.
    This is optional, but will improve security with your CodeIgniter installation.
    $config['encryption_key'] = 'YOUR_ENCRYPTION_KEY';
  • Update the 'global_xss_filtering' config setting to TRUE.
    This is optional, but will improve security with your CodeIgniter installation.
    $config['global_xss_filtering'] = TRUE;

This step must be completed to all flexi auth installations.

  • Update the 'sess_use_database' config setting to TRUE. This instructs CodeIgniter to save session data to the database rather than as a browser cookie.
    This is required as the auth session data is too big to store in a cookie.
    $config['sess_use_database'] = TRUE;
Update the 'config/database.php' file

This step must be completed if a database has not been configured with your CodeIgniter installation.

  • Update the database configuration settings located in the 'config/database.php' file to connect to your database.
Update the 'config/routes.php' file

This step is only required if you are installing the flexi auth demo.

  • Update the 'default_controller' to the sites home page.
    $route['default_controller'] = 'auth_lite/index';
Copy flexi auth files to CodeIgniter installation

The flexi auth repository is split into two sections, essential 'library files', and optional 'demo files'.

If you wish to install the demo, you will need to install both the 'library files' and the 'demo files'.

Note: Both folders also include an 'sql_dump' folder, see the 'Import SQL database dump' section below for further details.


Installing Library Files

To install the flexi auth library, copy the 'application' folder from 'library_files' to the root Codeigniter folder.

The 'application' folder in the 'library_files' folder includes the following folders and files:

  • config : 'flexi_auth.php'.
  • helpers : 'recaptcha_helper.php'.
  • lanaguge : 'english/flexi_auth_lang.php', (Plus any other language files...).
  • libraries : 'flexi_auth.php', 'flexi_auth_lite.php', 'MY_Form_validation.php' and the PHPASS library in the folder 'phpass'.
  • models : 'flexi_auth_model.php' and 'flexi_auth_lite_model.php'.

Installing Demo Files

To install the flexi auth demo, install the essential library files as described above, then also copy the 'application' and 'includes' folder from 'demo_files' to the root Codeigniter folder.

The 'demo_files' folder includes three folders in the root directory, 'application', 'includes', 'sql_dump' and a '.htaccess' file.

The 'application' folder contains the following folders and files:

  • controllers : 'auth.php', 'auth_admin.php', 'auth_lite.php', 'auth_public.php' and 'user_guide.php',
  • models : 'demo_auth_admin_model.php' and 'demo_auth_model.php'.
  • views : The folders 'demo', 'includes' and 'user_guide' and multiple php files.

The 'includes' folder contains the following folders and files:

  • css : 'global.css' and 'structure.css',
  • images : multiple images used throughout the demo.
  • js : 'global.js' and 'jquery.tools.tooltips.min.js'.
Update the '.htaccess' root CodeIgniter directory

If installing the flexi auth demo to a new CodeIgniter installation, you may wish to also copy the '.htaccess' file to the root CodeIgniter directory.
Note that you may need to change the path of the files 'RewriteBase /' to your servers Codeigniter installation.

Example
If the 'base_url' defined via the config file was $config['base_url'] = 'http://localhost/your_codeigniter_directory/'
Then the '.htaccess' file should be updated to RewriteBase /your_codeigniter_directory/.

Update 'base_url' and 'includes_dir' vars

If installing the flexi auth demo, the directories of the 'base_url' and 'includes_dir' vars need to be updated for the demo files to work correctly.

Open each of the demo controllers and update the 'base_url' and 'includes_dir' vars.
These can be found in the constructor of each controller and look like.

$this->load->vars('base_url', 'http://localhost/your_codeigniter_directory/');
$this->load->vars('includes_dir', 'http://localhost/your_codeigniter_directory/includes/');

The 'base_url' must refer to CodeIgniters root installation directory. 'includes_dir' must refer to the demo 'includes' folder.

Import SQL database dump

Import the SQL database dump file included with the flexi auth installation to your database.

If you are installing only the library files, install the sql dump within the 'library_files' folder. If installing the demo, install sql dump within the 'demo_files' folder.

The flexi auth 'library_files' folder includes the SQL dump file 'flexi_auth_database_dump.sql', which contains all the essential tables, columns and data that is required to utilise every feature within flexi auth.

The flexi auth 'demo_files' folder includes the SQL dump file 'flexi_auth_demo_database_dump.sql', which contains all the essential tables, but with example data and extra example tables that are utilised by the demo.

Static Salt for Password Hashing

It is very important that BEFORE you insert any users into the database, that you change the libraries static salt to your own unique value.

Once you start inserting users to the database, their password will have been hashed using this salt, therefore it cannot be later changed without reseting everyones passwords.

The static salt can be defined via the the config file.

$config['security']['static_salt'] = 'change-me!';

Google reCAPTCHA

If you are using the demo or intend to use Googles reCAPTCHA within your application, then you will need to get your own API keys in order to use the service.

Once you have obtained your keys, update the flexi auth libraries config file as follows.

$config['security']['recaptcha_public_key'] = 'ENTER_RECAPTCHA_PUBLIC_KEY_HERE';
$config['security']['recaptcha_private_key'] = 'ENTER_RECAPTCHA_PRIVATE_KEY_HERE';

That's it!

Next you can start configuring the flexi auth config file and database tables to match the setup that you require.

Once you have configured the site to your requirements, start building the site.

If starting from scratch, check out the demo flexi auth installation for live working examples of using many of the library functions.