PHPackages                             james-and-james-fulfilment/sf-doctrine-guard-plugin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. james-and-james-fulfilment/sf-doctrine-guard-plugin

ActiveSymfony1-plugin[Authentication &amp; Authorization](/categories/authentication)

james-and-james-fulfilment/sf-doctrine-guard-plugin
===================================================

Fork of identity management plugin for Symfony

v1.5.9(7y ago)097MITPHP

Since Sep 24Pushed 5y agoCompare

[ Source](https://github.com/JamesAndJamesFulfilment/sfDoctrineGuardPlugin)[ Packagist](https://packagist.org/packages/james-and-james-fulfilment/sf-doctrine-guard-plugin)[ RSS](/packages/james-and-james-fulfilment-sf-doctrine-guard-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

```
# sfGuardDoctrine plugin (for symfony 1.3) #

The `sfDoctrineGuardPlugin` is a symfony plugin that provides authentication and
authorization features above the standard security feature of symfony.

It gives you the model (user, group and permission objects) and the modules
(backend and frontend) to secure your symfony application in a minute in
a configurable plugin.

## Installation ##

  * Install the plugin (via a package)

        symfony plugin:install sfDoctrineGuardPlugin

  * Install the plugin (via a Subversion checkout)

        svn co http//svn.symfony-project.com/plugins/sfDoctrineGuardPlugin/trunk plugins/sfDoctrineGuardPlugin

  * Activate the plugin in the `config/ProjectConfiguration.class.php`

        [php]
        class ProjectConfiguration extends sfProjectConfiguration
        {
          public function setup()
          {
            $this->enablePlugins(array(
              'sfDoctrinePlugin',
              'sfDoctrineGuardPlugin',
              '...'
            ));
          }
        }

  * Rebuild your model

        symfony doctrine:build-model
        symfony doctrine:build-sql

  * Update you database tables by starting from scratch (it will delete all
    the existing tables, then re-create them):

        symfony doctrine:insert-sql

    or do everything with one command

        symfony doctrine-build-all-reload frontend

    or you can just create the new tables by using the generated SQL
    statements in `data/sql/plugins.sfGuardAuth.lib.model.schema.sql`

  * Load default fixtures (optional - it creates a superadmin user)

        mkdir data/fixtures/
        cp plugins/sfDoctrineGuardPlugin/data/fixtures/fixtures.yml.sample data/fixtures/sfGuard.yml

        symfony doctrine:data-load frontend # replace frontend with the name of one of your application

  * Enable one or more modules in your `settings.yml` (optional)
    * For your backend application:  sfGuardUser, sfGuardGroup, sfGuardPermission

              all:
                .settings:
                  enabled_modules:      [default, sfGuardGroup, sfGuardUser, sfGuardPermission]

    * For your frontend application: sfGuardAuth

              all:
                .settings:
                  enabled_modules:      [default, sfGuardAuth]

  * Clear you cache

        symfony cc

  * Optionally add the "Remember Me" filter to `filters.yml` above the security filter:

        [yml]
        remember_me:
          class: sfGuardRememberMeFilter

        security: ~

### Secure your application ###

To secure a symfony application:

  * Enable the module `sfGuardAuth` in `settings.yml`

        all:
          .settings:
            enabled_modules: [..., sfGuardAuth]

  * Change the default login and secure modules in `settings.yml`

        login_module:           sfGuardAuth
        login_action:           signin

        secure_module:          sfGuardAuth
        secure_action:          secure

  * Change the parent class in `myUser.class.php`

        class myUser extends sfGuardSecurityUser
        {
        }

  * Optionally add the following routing rules to `routing.yml`

        sf_guard_signin:
          url:   /login
          param: { module: sfGuardAuth, action: signin }

        sf_guard_signout:
          url:   /logout
          param: { module: sfGuardAuth, action: signout }

        sf_guard_password:
          url:   /request_password
          param: { module: sfGuardAuth, action: password }

    You can customize the `url` parameter of each route.
    N.B.: You must have a `homepage` routing rule (used when a user sign out)

    These routes are automatically registered by the plugin if the module `sfGuardAuth`
    is enabled unless you defined `sf_guard_plugin_routes_register` to false
    in the `app.yml` configuration file:

        all:
          sf_guard_plugin:
            routes_register: false

  * Secure some modules or your entire application in `security.yml`

        default:
          is_secure: true

  * You're done. Now, if you try to access a secure page, you will be redirected
    to the login page.
    If you have loaded the default fixture file, try to login with `admin` as
    username and `admin` as password.

## Manage your users, permissions and groups ##

To be able to manage your users, permissions and groups, `sfDoctrineGuardPlugin` comes
with 3 modules that can be integrated in your backend application.
These modules are auto-generated thanks to the symfony admin generator.

  * Enable the modules in `settings.yml`

        all:
          .settings:
            enabled_modules: [..., sfGuardGroup, sfGuardPermission, sfGuardUser]

  * Access the modules with the default route:

    http://www.example.com/backend.php/sfGuardUser

## Customize sfGuardAuth module templates ##

By default, `sfGuardAuth` module comes with 2 very simple templates:

  * `signinSuccess.php`
  * `secureSuccess.php`

If you want to customize one of these templates:

  * Create a `sfGuardAuth` module in your application (don't use the
    `init-module` task, just create a `sfGuardAuth` directory)

  * Create a template with the name of the template you want to customize in
    the `sfGuardAuth/templates` directory

  * symfony now renders your template instead of the default one

## Customize `sfGuardAuth` module actions ##

If you want to customize or add methods to the sfGuardAuth:

  * Create a `sfGuardAuth` module in your application

  * Create an `actions.class.php` file in your `actions` directory that inherit
    from `BasesfGuardAuthActions` (don't forget to include the `BasesfGuardAuthActions`
    as it can't be autoloaded by symfony)
