vanio/vanio-user-bundle

Symfony2 Bundle integrating FOSUserBundle and HWIOAuthBundle with some additional features and sane defaults

Installs: 6 752

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 8

Forks: 1

Open Issues: 0

Type:symfony-bundle

v0.3.0 2018-09-14 03:46 UTC

README

Build Status PHP7.1 License

A Symfony2 Bundle integrating FOSUserBundle and HWIOauthBundle with some additional features and sane defaults.

Installation

Installation can be done as usually using composer. composer require vanio/vanio-user-bundle

You can also install HWIOAuthBundle optionally if you want to support authentication via social accounts. composer require php-http/guzzle6-adapter php-http/httplug-bundle hwi/oauth-bundle

Next step is to register this bundle as well as bundles it depends on inside your AppKernel.

// app/AppKernel.php
// ...

class AppKernel extends Kernel
{
    // ...

    public function registerBundles(): array
    {
        $bundles = [
            // ...
            new FOS\UserBundle\FOSUserBundle,
            new Http\HttplugBundle\HttplugBundle, // Optional, dependency of HWIOAuthBundle
            new HWI\Bundle\OAuthBundle\HWIOAuthBundle, // Optional
            new Vanio\UserBundle\VanioUserBundle,
            new Vanio\UserBundle\VanioWebBundle,
        ];

        // ...
    }
}

Default Configuration

firewall_name: ~ # firewall name, auto-detected from security configuration when empty
email_only: false # whether to completely omit username and use email only
custom_storage_validation: false # whether to disable predefined uniqueness validation
use_flash_notifications: true # whether to enable notifications using flash messages (notify also on login and logout as an addition to FOSUserBundle)
registration_target_path: ~ # target path used for redirection after completed registration instead of default static pages
pass_target_path: # whether to pass referer in URL query parameter and use it as target path
    enabled: false
    default_target_path: / # default value when target path is not present, default_target_path option inside security configuration is ignored
    target_path_parameter: _target_path: # name of the parameter
    ignored_routes: [] # route names to ignore
    ignored_route_prefixes: # route name prefixes to ignore, the default ones are always merged in
        - fos_user_security_
        - fos_user_registration_
        - fos_user_resetting_
        - hwi_oauth_

social_authentication: ~ # whether to enable social authentication, automatically enabled when HWIOAuthUserBundle is installed
social_registration_form: # social registration form configuration
    type: Vanio\UserBundle\Form\SocialRegistrationFormType # form type
    name: hwi_oauth_registration_form # form name
    validation_groups: [SocialRegistration] # form validation groups

All these values are available as container parameters. They are prefixed using vanio_user. prefix.
This bundle prepends some defaults of SecurityBundle, FOSUserBundle and HWIOAuthBundle based on these configuration values to make the configuration easier.

The default prepended values are:

security:
    encoders:
        FOS\UserBundle\Model: bcrypt
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username # or fos_user.user_provider.username_email when %vanio_user.email_only%

fos_user:
    firewall_name: %vanio_user.firewall_name%
    use_listener: false
    use_flash_notifications: %vanio_user.use_flash_notifications%
    registration:
        form:
            type: FOS\UserBundle\Form\Type\RegistrationFormType # or Vanio\UserBundle\Form\EmailOnlyRegistration when %vanio_user.email_only%
        confirmation:
            template: VanioUserBundle:Registration:email.html.twig
    resetting:
        email:
            template: VanioUserBundle:Resetting:email.html.twig
    profile:
        form:
            type: FOS\UserBundle\Form\Type\ProfileFormType # or Vanio\UserBundle\Form\EmailOnlyProfileType when %vanio_user.email_only%
    service:
        mailer: fos_user.mailer.twig_swift

hwi_oauth:
    firewall_names: [%vanio_user.firewall_name%]