DavertMik / doAuthPlugin

Symfony new authentication / user managemant system
MIT License
19 stars 6 forks source link

doAuthPlugin

Inspired by sfGuardPlugin an easy-to-use new authorization system. doAuth is ready to work out of the box with just a few configuration changes. It takes all the common user functionality - User authorization by login and password, registration, activation by email, password reset. If you don't need sfGuard permissions system but a simple user module that works, you should try doAuth. Great for a new symfony 1.4 projects.

Features

Coming Soon: doAccess plugin that adds a permissions functionality on top of doAuth plugin.

Installation

You are ready to use. Try to access /register, /login, /logout routes. By default doAuth automaticaly signs user is on registration and sends email with username and password.

Usage

Access your user model from a class User. (well, is very common thing, but should be noted for sfGuardUser users)

Customization

Registration

You can extend registration form in your own way. Here are 2 typical cases.

Sometimes you need more complex schema. For example, register user with different profile types, for example: Client and Developer. In this case you need to embed a Client and Developer forms into RegistrationForm depending on request parameters. This can't be made just by extending registration class. In this case you can use an events to extend current Register action with your logic.

Use ['user.pre_register'] event to access registration action, get request parameters, extend form, do everything you need.

Codes and Security

doAuthPlugin generates hashes for remember filter, activation code, password reset code and a new password for user on request.

Here are the principles that doAuth follows to create user codes:

If you are unhappy with provided methods, you can override them, following this instructions:

(Great thanks to Laurent Bachelier and Andrei Dziahel)

Configuration

This options are stored in plugins/doAuth/config/app.sample.yml. If you want to change some settings - copy them to your app.yml file.

    all:
      doAuth:
        # password encrypting algorithm
        algorithm_callable: sha1
        # function for delegating password check
        check_password_callable: false
        # coookie
        remember_cookie_name: doRemember
          # expiration time (in secs), currently 1 year
        remember_cookie_expiration_age: 31536000
        # use user activation
        activation: false
        # where to redirect after request for password reset
        reset_password_url: '@homepage'
        # signin redirect
        signin_url: '@homepage'
        #signout url
        signout_url: '@homepage'
        # register standard routes
        routes_register: true

      doAuth_register:
        # forward registration to next module
        # syntax: [module, action]
        forward: ~
        # or redirect to current path
        redirect_path: '@homepage'
        # auto sign in after registration
        signin: true

      doAuth_email:
        # activate by email if activation is on
        activation: true
        # send registration notification
        registration: true
        # sender email
        from: mailer@currenthost.com
        # module where email partials are stored.
        # default is module from controller
        module: false

Events

Here is a list of all events that are fired by doAuthPlugin:

Basically 2 last events are used to send emails.

Alternative to events (new in 0.9.5)

To extend user actions you don't have to assign listeners to events. You can also override this dummy methods in your controller.

Tasks (new in 0.9.5)

Added several tasks for user management

I18n

All the messages and templates are I18n-ready. Please check doAuthMailer class to add translations to email subjects and doAuthActions to translate flash messages

Contribute

You can always fork this project on Github. http://github.com/DavertMik/doAuthPlugin Bugfixes, enhancements, bugreports are always welcome.

TODO