icon for lab

CT310

Recitation 16 - Fuel Authentication

In this recitation, we will:


Javascript quiz Thursday! Be sure to have Part 1 done by then!

Authentication Packages with in Fuel: SimpleAuth, OrmAuth

Contains drivers that handle users, groups, roles, and permissions

OrmAuth

Similar to SimpleAuth, but uses a database to store all its data

Allows for direct assignment of permissions to users/groups and other features to provide a more "fine-grained permission system".

  1. Edit the "Auth" configuration files
  2. Find and copy these files: /fuel/packages/auth/config/auth.php and /fuel/packages/auth/config/ormauth.php; to your main /fuel/app/config/ folder.

    Change the "driver" option in /fuel/app/config/auth.php on line 25 from Simpleauth to Ormauth (case-sensitive!). For now, change your "salt" option to an empty string.

  3. Edit App config file
  4. In /fuel/app/config/config.php, we'll need to uncomment parts of the "always_load" section.

    The lines that need to be uncommented are 262, 275-278, and 314. It should look similar to what is below:

    	
             .
             .
             .
             
            /**************************************************************************/
    	/* Always Load                                                            */
    	/**************************************************************************/
    	'always_load'  => array(    <----262
    
    		/**
    		 * These packages are loaded on Fuel's startup.
    		 * You can specify them in the following manner:
    		 *
    		 * array('auth'); // This will assume the packages are in PKGPATH
    		 *
    		 * // Use this format to specify the path to the package explicitly
    		 * array(
    		 *     array('auth'	=> PKGPATH.'auth/')
    		 * );
    		 */
    		'packages'  => array(    <----275
    			'orm',
    			'auth',
    		),
    
    		/**
    		 * These modules are always loaded on Fuel's startup. You can specify them
    		 * in the following manner:
    		 
             .
             .
             .
    
        ),        <----314
    

Down the source files here and note that there is no model for this example.

This authentication stuff can be pretty complicated so I will try to break it down in the lab video more.

Setup

  1. Download the source files and place them in the appropriate locations
  2. Once you've done this you should be able to load the app at your normal fuel path ending authenticationexample
  3. https://cs.colostate.edu/~EID/ct310/index/authenticationexample
  4. Uncomment the code at the bottom of the authenticationexample controller. This is the code to create the database table for users.
  5. Trigger that code by going to the controller destination https://cs.colostate.edu/~EID/ct310/index/authenticationexample/createtables
  6. Check your database to see the tables were created.
  7. Comment out or delete the create tables code.
  8. Now you should have a working version of the app.

Use this code as an opportunity to read and learn about authentication. Note that I had to use PHP sessions ($_SESSION) because the standard authentication code was not working for me.

Also note that the code / styles were generated using bootstrap 5, if you are interested here is a link: Bootstrap