Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Extending SimpleAuth
  • HI,

    I am planning to write my own Auth driver or extend the SimpleAuth driver.

    My aim is to be able to give rights directly to a user. I know there is a DbAcl package, but that does not fit my need.

    My plan is to extend/rewrite the SimpleAuth driver. Users, groups and roles would be stored in database. I would write two group drivers: one is for a group, and one is for a user. The group-role and the user-role many-many relations would have the same syntax.


    Is it a good idea? Or I should write my own package or extend Sentry or Warden to have this extra.

    Thanks,
    Mark

    P.s. Sorry for my bad english :)
  • I have done exactly the same, I've extended both 'login' and 'acl' to add custom features.
  • Is it in the 1.5/develop branch as a new feature or I should read the docs more carefully :)?
  • What do you mean?

    The custom features I was talking about were application specific, hence the extension.
  • Oh, I see. You have done it in your application.

    As I can see, the ACL driver gets the roles from the Group driver, so I was about to extend the Group driver, to create two group driver actually. One is for the normal group and one is to return the roles of the user, so that group driver would be for a not-existing group with only one user.

    But now I've learned the code a bit more, and now I see, that this way I have to check the two groups in my application.So my next idea: if I create two ACL drivers, and I define them in my ONE group driver, then I can check for the group rights in one, and the user rights in the other one. And the two ACL will be automatically called.

    Am I right?
  • What I've done is add a rights structure for a user similar to the one defined for a group (the simpleauth 'roles' array in the config file). I store this in the users profile_fields in the database.

    Then in my simpleacl extension, I have overloaded the has_access method, which merged the current user rights with the group rights, and then checks for access the normal way.
  • Thanks Harro. Maybe this is the easiest way.
  • One more question:  How do you extend the simple auth class? In the auth package directory or the app directory?
  • HarroHarro
    Accepted Answer
    in app, using the same folder structure, and then define the class in the app bootstrap.

    My app's bootstrap has:
    Autoloader::add_classes(array(
        // our custom auth classes
        'Auth_Login_SimpleAuth'        => APPPATH.'classes/auth/login/simpleauth.php',
        'Auth_Acl_SimpleAcl'        => APPPATH.'classes/auth/acl/simpleacl.php',
        // our fieldset extensions
        'Fieldset_Field'            => APPPATH.'classes/core/fieldset/field.php',
        // our lang extensions
        'Lang'                        => APPPATH.'classes/core/lang.php',
        // our view extensions
        'View'                        => APPPATH.'classes/core/view.php',
    ));

Howdy, Stranger!

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

In this Discussion