Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Sentry - Authentication Package
  • Cartalyst is proud to announce the official launch of Sentry. Sentry is an open source authentication package built for FuelPHP and will also be the authentication system behind Cartalyst. Sentry was built to be powerful and secure, but simple enough for developers to understand, implement and customize easily. With our initial launch, Sentry will have the following feautres: Authentication (via username or email)
    Authorization
    Groups / Roles
    Remember Me
    User Suspension / Login Attempt Limiter
    Password Reset
    User Activation
    User Metadata Further information about sentry and cartalyst here:
    http://blog.cartalyst.com/2011/12/introducing-sentry-a-fuelphp-authentication-package/ Repo and Docs here:
    Repository: https://github.com/cartalyst/sentry-fuel
    Docs: http://cartalyst.github.com/sentry/
  • Harro Verton wrote on Wednesday 4th of January 2012:
    I don't see this to be an oil bug. The question is, why does Sentry's migrations require the package to be loaded? The answer is: it tries to load the sentry config file from the package. So, the bug is that the migration doesn't ensure that the package is loaded. This can be fixed by adding "\Package::load('sentry');" in the migrations file, in between the namespace definition and the class definition.

    Hmm.. I'll have to add that in, didn't realize it worked that way. Always just did the always load. As to all the other issues, they should all be sorted out now.
  • Daniel Petrie wrote on Wednesday 4th of January 2012:
    Hmm.. I'll have to add that in, didn't realize it worked that way. Always just did the always load.

    To be fair, the installation instructions does say to set the package to always load. I just assumed that was to make it *work* rather than to install it. I'll read installation instructions more carefully next time, but belt and braces never did any harm.
  • Peter wrote on Wednesday 23rd of May 2012:
    Will Sentry 2 (with ACL?) be developed for FuelPHP too or just for Laravel?
    Looks like there's a 2.0 dev version for Fuel:
    https://github.com/cartalyst/sentry-fuel/tree/2.0/develop
  • For those interested in or new to Sentry.. we now have a screencast up with an intro on how to create a registration/login system with it. http://blog.cartalyst.com/2012/02/sentry-screencastic/
  • Wanted to say thanks for this package. Makes all the registration process / login simple and secure. I do have one question. If I want to add some variables to the session created by Sentry, how do I grab the right instance. Basically when I log a user in I want to add some data to the cookie like a bool admin. What I'm doing now is just using the in_group method like so
                        $valid_login = Sentry::login($email, $password, true);
    
                        if ($valid_login) {
    
    
                            if (Sentry::user()->in_group(1)) { // or in_group('editors');
                                
                                Session::set('admin', true);
                            }
    
                            Response::redirect('home');
                            return true;
                        } else {
    
                            Session::set_flash('error', 'invalid email / password combo');
                            return false;
                        }
    

    But when I do this it looks like the Session::set is just setting the default fuelcid session separate from the sentry session I also tried grabbing it like this
         
           $session = Session::instance('sentry_rm');
    

    but that just returns a null value.
  • Note to everyone using sentry, the repo name has changed to sentry-fuel from sentry.
  • dpetrie wrote on Tuesday 22nd of May 2012:
    Note to everyone using sentry, the repo name has changed to sentry-fuel from sentry.

    Thanks. Will Sentry 2 (with ACL?) be developed for FuelPHP too or just for Laravel?
  • Sentry only creates 1 session var which is the user_id, and that is it. It's not its own instance or anything, you just have to grab it from the session with whatever you named it in the config ( which is defaulted to 'sentry_user' ). So Session::get('sentry_user') by default if you wanted to grab the id that way for some reason. If you want to add data to the session, just do it how you normally would. The 'sentry_rm' is for the cookie stored for remember me functionality and that is it. It stores a hash value to log the user back in the next time they visit the site.
  • Harro Verton wrote on Wednesday 28th of December 2011:
    I don't really like using levels, too many nasty experiences with it when your authorisation gets more complex. I now tend to use it as a boolean: 0 = user, 1 = administrator. As for roles, a role is just a name, so you could use groups for it. I've send a pull request a few days ago to support nested groups, allowing for a bit more flexibility.
    I too use complex roles and cant seem to get my head around nested groups and there is nothing mentioned in the docs. WanWizard any chance you can give an example of how to use nested groups for roles. Thanks
  • I'm not sure what has been done to it recently. I added a column called 'parent' to the groups table, but I now see it is defined in the migrations as varchar(200). You'll have to talk to dpetrie about that. The idea behind this parent column is that you can create a group called 'forum boss', which has rights to all forums, and groups called 'forum_A' and 'forum_B'. If you set the parent of these two groups to 'forum boss', any rights you assign to these two groups will also apply to the parent group (so rights bubble up the tree). This means that a user who has the 'forum boss' group will inherit all rights assigned to underlying groups. Hope that explains it a bit...
  • Thanks WanWizard gives me a little more understanding. It doesn't really do roles (create, read, update, delete) its all based on the level. Might have a go at adding roles, by creating a Sentry_Role class to manage/checking the roles. Adding tables 'groups_roles' and 'roles' and 'groups_roles' will have columns group_id, role_id and 'roles' table will have columns id, name and role. The column role will be set as text to store serialized data of the role in same format as fuelphp's Auth package: $role = array(
    'website' => array('create', 'update', 'delete'),
    'admin' => array('create', 'read', 'update', 'delete'),
    ); $role = serialize($role); Prob start in next few weeks if I get round to it :)
  • We haven't put in role support yet, jut basic groups. It is planned for down the road though when we get a chance to start adding new features again. As to the nested groups, I don't think we've touched any of your code that you wrote for it WanWizard, I just added the column to migrations.
  • Daniel Petrie wrote on Saturday 21st of January 2012:
    We haven't put in role support yet, jut basic groups. It is planned for down the road though when we get a chance to start adding new features again. As to the nested groups, I don't think we've touched any of your code that you wrote for it WanWizard, I just added the column to migrations.

    Thanks all Ill check up on it when I come to adding auth to my project. Great work so far...
  • Daniel Petrie wrote on Saturday 21st of January 2012:
    I don't think we've touched any of your code that you wrote for it WanWizard, I just added the column to migrations.
    I think something went wrong there, the parent should be a group id, so an int like the primary key. It's now defined as varchar(200)...
  • Harro Verton wrote on Sunday 22nd of January 2012:
    Daniel Petrie wrote on Saturday 21st of January 2012:
    I don't think we've touched any of your code that you wrote for it WanWizard, I just added the column to migrations.
    I think something went wrong there, the parent should be a group id, so an int like the primary key. It's now defined as varchar(200)...

    Ah, I'll get to fixing that
  • Hi Daniel, Looks really great, well done. I've been using the Auth package with SimpleAuth but came across some difficulties and some - for me - illogical things but I've made (inefficient) work-arounds for these things. That's why I really like this package. Sentry looks way more logical to me and I'm definitely going to test it and use it for my next project.
  • Yes, it looks an Auth package with real world functionality. Thank you.
    I'll check the code, too.
  • hello, i'm a beginner user for fuel and testing auth(sentry) package. When I migrate the sentry package, it inserted users table with id, username & etc.... I wonder can i use user_id instead of id. how can I change that?
  • Sentry 1.1 is now live along with a new dedicated site for Sentry and updated docs. Post: http://blog.cartalyst.com/2012/02/sentry-1-1-and-site-launched/
    Site: http://sentry.cartalyst.com
  • alt 332 wrote on Monday 23rd of January 2012:
    hello, i'm a beginner user for fuel and testing auth(sentry) package. When I migrate the sentry package, it inserted users table with id, username & etc.... I wonder can i use user_id instead of id. how can I change that?

    To switch id to user_id you would need to change quite a bit of code in the sentry package itself to get it to work. Is there a reason you want 'user_id' instead of just 'id' ?
  • thanks for your help dpetrie ^^, I used user_id instead of id on the other tables in my prj that's why :)
  • We are looking for feedback on Sentry. http://bit.ly/wCpDg8
  • Thanks for the great package.
    Been looking at the structure and how I could possibly build the groups and roles system.
    I see there is 'level' for each group, but couldn't figure out yet what's the best way to implement roles through this.
    Is there an example or a simple guide on how to implement it?
    Thanks!
  • I don't really like using levels, too many nasty experiences with it when your authorisation gets more complex. I now tend to use it as a boolean: 0 = user, 1 = administrator. As for roles, a role is just a name, so you could use groups for it. I've send a pull request a few days ago to support nested groups, allowing for a bit more flexibility.
  • Thank you. I was thinking of making it like a bit field starting with least permission.
    I have more than just user / admin

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion