EllisLab text mark
Advanced Search
3 of 88
3
   
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 03 March 2010 08:39 PM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Joined: 2009-10-04
189 posts

Thanks for the reply.

I will use the Ion Auth for the project. Thanks a lot!

I will use postgreSQL database, here is the model for test purposes.

CREATE TABLE "users" (
    
"id" SERIAL NOT NULL,
    
"group_id" int4 NOT NULL,
    
"ip_address" char(16NOT NULL,
    
"username" varchar(15NOT NULL,
    
"password" varchar(40NOT NULL,
    
"email" varchar(40NOT NULL,
    
"activation_code" varchar(40),
    
"forgotten_password_code" varchar(40),
    
"active" int4,
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0),
  
CONSTRAINT "check_group_id" CHECK(group_id >= 0),
  
CONSTRAINT "check_active" CHECK(active >= 0)
);


CREATE TABLE "meta" (
    
"id" SERIAL NOT NULL,
    
"user_id" int4,
    
"first_name" varchar(50),
    
"last_name" varchar(50),
    
"company" varchar(100),
    
"phone" varchar(20),
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0),
  
CONSTRAINT "check_user_id" CHECK(user_id >= 0)
);


CREATE TABLE "groups" (
    
"id" SERIAL NOT NULL,
    
"name" varchar(20NOT NULL,
    
"description" varchar(100NOT NULL,
  
PRIMARY KEY("id"),
  
CONSTRAINT "check_id" CHECK(id >= 0)
);


INSERT INTO groups (idnamedescriptionVALUES
    
(1,'admin','Administrator'),
    (
2,'members','General User');
    
INSERT INTO meta (iduser_idfirst_namelast_namecompanyphoneVALUES
    
('1','1','Admin','istrator','ADMIN','0');
    
INSERT INTO users (idgroup_idip_addressusernamepasswordemailactivation_codeforgotten_password_codeactiveVALUES
    
('1','1','127.0.0.1','administrator','59beecdf7fc966e2f17fd8f65a4a9aeb09d4a3d4','admin@admin.com','',NULL,'1'); 

In the project I will not use postgreSQL sequences(same as auto increment of MySQL). I will use triggers instead.

Here to share.


Best Regards,

 
Posted: 03 March 2010 09:16 PM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

joytopia,

Thank you for finding the error and the fix.  I just pushed the changes to git.


Thanks!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 09:21 PM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Sinclair,

Github’s being stupid right now but as soon as it’s back up I’ll push your file.


Thanks for the file!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 11:22 PM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-23
20 posts

Ben-

I’m finding your Ion Auth to be a great starting point for my project that handles memberships on a site. Thanks for your work…I agree that keeping it lightweight and generic is good.

Joytopia-

Would you mind sharing your create_user method and view? I’m not missing something here, right? The model has the logic to handle it, but there is not currently a method in the controller.

Thanks!

 Signature 

Famous Quotes

 
Posted: 03 March 2010 11:26 PM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Darren,

Thanks man!

The github repo is now updated with Joytopia’s fix.


The method to use to create a user is $this->ion_auth->register().  There is an example of using it in the controller’s create_user() method.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 03 March 2010 11:37 PM   [ Ignore ]   [ # 46 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-23
20 posts

ahhh….sorry. I meant the update_user function. I’m thinking that is a function that lets you (or the user) update their own (meta) information.

 Signature 

Famous Quotes

 
Posted: 04 March 2010 02:14 AM   [ Ignore ]   [ # 47 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

Darren,

It’s the update_user() method of the library, so $this->ion_auth->update_user($id, $data) and $data is an array of the fields to update.

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 04 March 2010 02:16 AM   [ Ignore ]   [ # 48 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-23
20 posts

Gotcha Ben…thanks.

 Signature 

Famous Quotes

 
Posted: 04 March 2010 02:17 AM   [ Ignore ]   [ # 49 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

All,

I just pushed the “remember me” functionality to github.


Please abuse it like a crazed maniac and let me know of any errors you find.


http://github.com/benedmunds/CodeIgniter-Ion-Auth


Thanks!

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 07 March 2010 07:48 PM   [ Ignore ]   [ # 50 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-03
11 posts

I think there’s an error in the library constructor

$email $this->ci->config->item('email'); 

Should be ‘admin_email’??

Also, the $this->data[‘sample’] syntax is generating errors for me. Replacing with $data[‘somedata’] seems to work for me. Are you using a templating or view library?

 
Posted: 08 March 2010 03:05 AM   [ Ignore ]   [ # 51 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-26
818 posts

James,

I removed that loading of the email config as it isn’t used.  Thanks for finding that.

As for the $this->data,  I’m using a MY_Controller where I declare $data so all you have to do for the examples is either change it to $data like you did or declare $data in your controller outside of the methods so you can reference it as $this->data.

Make sense?

 Signature 

BenEdmunds.com

Contact Me:                                    My Code: 

  ben.edmunds@gmail.com            Github
  @benedmunds

 
Posted: 08 March 2010 02:52 PM   [ Ignore ]   [ # 52 ]   [ Rating: 0 ]
Avatar
Joined: 2007-12-03
11 posts

Yeah, thanks!

 
Posted: 10 March 2010 06:10 AM   [ Ignore ]   [ # 53 ]   [ Rating: 0 ]
Joined: 2010-03-10
1 posts

Hi Ben,

Lovin’ the library. I added it to a clean CI install for testing. In the constructor, if using the ‘remember me’ feature for auto-login I thought it would be good to test if the user is logged in first, it would save running the DB queries in the login_remembered_user function. Or am I missing something / adding a problem?

Ion_auth.php __construct()

public function __construct()
    
{
        $this
->ci =& get_instance();
        
$this->ci->load->config('ion_auth');
        
$this->ci->load->library('email');
        
$this->ci->load->model('ion_auth_model');
        
$this->ci->load->helper('cookie');
        
        
//auto-login the user if they are remembered
        
if (!$this->logged_in() && get_cookie('identity') && get_cookie('remember_code'))
        
{
            $this
->ci->ion_auth_model->login_remembered_user();
        
}
    } 

Owen

 
Posted: 11 March 2010 02:03 PM   [ Ignore ]   [ # 54 ]   [ Rating: 0 ]
Joined: 2010-02-03
5 posts

Dear All

I have seen some comments e.g. “Professional Codeigniter - Thomas Myer 2008” that says:

If you need to have secure logins and authentication use PHP sessions instead [of CI sessions].  (p. 59)

I am interested in whether other Forum members think that a system like Ion-Auth, used with CI 1.7 encrypted cookies and database storage mean that Thomas Myer’s comments no longer hold true.

Thanks in Advance

Alec

 
Posted: 12 March 2010 08:45 AM   [ Ignore ]   [ # 55 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts

Well 1.7.0 was released the same year as that book, so not much code has changed.

I think Tom may have just overlooked this option when writing that section. Either way, it is irrelevant as encrypted cookies are perfectly secure (if you have an encryption key!).

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

 
3 of 88
3