Part of the EllisLab Network
   
1 of 118
1
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 10 February 2010 07:00 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  884
Joined  07-26-2009

Hey everybody,

Just wanted to “officially” announce the release of Ion_Auth.  It’s based on Redux Auth 2 but with a whole lot more awesomeness added in.

You can get it here:
http://github.com/benedmunds/CodeIgniter-Ion-Auth


Redux Auth 2 had a lot of potential.  It’s lightweight, simple, and clean,
but had a ton of bugs and was missing some key features.

So I’ve refactored the code and added new methods and functions with the much
appreciated help of Phil Sturgeon.

INSTALLATION:
Just copy the files from this package to the corresponding folder in your
application folder.  For example, copy Ion_auth/config/ion_auth.php to
system/application/config/ion_auth.php.

USING THE LIBRARY: 
In the package you will find example usage code in the controllers and views
folders.  The example code isn’t the most beautiful code you’ll ever see but
it’ll show you how to use the library and it’s nice and generic so it doesn’t
require a MY_controller or anything but it will be easy to add render() methods
if needed since there is only one load->view() per controller method. 


IMPORTANT: 
It is highly recommended that you use encrypted database sessions for security!

Feel free to send me an email if you have any problems.


Thanks,

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

Profile
 
 
Posted: 10 February 2010 10:45 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  7
Joined  10-12-2009

Hi Ben,

I was just looking for a nice authentication library. I really like redux but it seems to be dead now, unfortunately. So I like what you’re doing.

I saw in your sample controller that you called functions like $this->ion_auth->logged_in() or $this->ion_auth->is_admin(). Is it possible with Ion Auth to define custom roles like for example $this->ion_auth->is_moderator() without having to modify the library?

I just released a new version of TagMVC that could use a feature like that.

Cheers,

Julien

Profile
 
 
Posted: 10 February 2010 11:33 PM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  884
Joined  07-26-2009

Thanks Julien,

You can use ->is_group(‘moderator’)


Enjoy,

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

Profile
 
 
Posted: 11 February 2010 08:58 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  3
Joined  02-11-2010

Hi Ben,

Giving your library a shot. Perfect timing for my project. Thanks for sharing!

I’m still learning codeigniter but I found a couple little bugs and also have a suggestion to pass by you. I can keep posting to this thread if this is helpful.

Thanks again.


auth.php, line 167, remove line:
echo $reset; //debug

auth/index.php, line 21, change line:
<td><?php echo $user[‘group_description’];?></td>
to
<td><?php echo $user[‘group’];?></td>

Also would you ever consider adding a session variable ‘identity’, so the code maps more cleanly to which identity you choose in config?

ion_auth_model, line 537:
$this->session->set_userdata(‘identity’,  $result->{$this->identity_column});

And delete in logout
Ion_auth.php, line 255:
$this->ci->session->unset_userdata(‘identity’);

(Or maybe do the unsetting in the model)

Thanks once more.

Profile
 
 
Posted: 11 February 2010 11:14 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  884
Joined  07-26-2009

Hey betabeta,

Thanks for the feedback!


The first two errors are fixed now and for the question about identity you can use

$identity $this->session->userdata($this->config->item('identity')); 

will this do what you need?

 

Thanks!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

Profile
 
 
Posted: 12 February 2010 01:00 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  3
Joined  02-11-2010

Thanks! That’s a much better way to do it.

Profile
 
 
Posted: 12 February 2010 03:43 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  3
Joined  02-11-2010

Hi Ben,

A couple more for you to fix activation emails:

controller/auth.php

Line 211 to 213:
// delete lines because new users are the ones that need to create accounts

if (!$this->ion_auth->logged_in() || !$this->ion_auth->is_admin()) {
    redirect
('auth''refresh');


libraries/Ion_auth.php

Line 203:
// deactivate takes $id instead of $username

$deactivate $this->ci->ion_auth_model->deactivate($register); 

Line 212:
// need to add ->row() or else can’t get properties for email

$user            $this->ci->ion_auth_model->get_user($register)->row(); 


Also it’s weird to me that session vars are set in the model but deleted in the library.


I hope this is helpful.


EDIT: The activation email bugs mention here were resolved in the source as of 2010 Feb 13. Thanks.

Profile
 
 
Posted: 12 February 2010 04:15 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  4
Joined  02-10-2010

Hey!

How do I fetch eg. user id (or any data) from database who’s currently logged in?

Profile
 
 
Posted: 12 February 2010 04:16 PM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  884
Joined  07-26-2009

Markko,

$user = $this->ion_auth->get_user();

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

Profile
 
 
Posted: 13 February 2010 04:16 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  4
Joined  02-10-2010

Okey thanks Ben!

// Edit
Are you planning to make some documentation for your awesome Auth? I know this should be simple but what can I do when i’m still CI noob!? wink

Profile
 
 
Posted: 13 February 2010 10:40 AM   [ Ignore ]   [ # 10 ]  
Grad Student
Avatar
Rank
Total Posts:  77
Joined  11-29-2007

Hi Ben,

Your auth seems promising, are you able to keep it up to date for the next couple of years?

Thanks a lot for your time mate.
atno

 Signature 

Junior PHP dev looking for a project to get started with.

Profile
 
 
   
1 of 118
1