PHPackages                             bitgrave/persona-bundle - 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. bitgrave/persona-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

bitgrave/persona-bundle
=======================

Integrate mozilla persona authentification service into your Symfony2 application.

1.0.0(12y ago)2203MITPHPPHP &gt;=5.3.2

Since Aug 28Pushed 12y agoCompare

[ Source](https://github.com/paterik/BGPersonaBundle)[ Packagist](https://packagist.org/packages/bitgrave/persona-bundle)[ Docs](https://github.com/paterik/BGPersonaBundle)[ RSS](/packages/bitgrave-persona-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Introduction
============

[](#introduction)

This Bundle enables integration of mozillas PERSONA verification API. It also provides a Symfony2 authentication provider so that users can login to a Symfony2 via persona's Remote Verification API. Furthermore via custom user provider support the persona login can also be integrated with some other data sources like the database based solution provided by the famous FOSUserBundle.

Note that logging in a user requires 3 steps:

1. the user must have a valid personal authentification account
2. you have to trigger the symfony2 login
3. add the persona login button (twig helper) inside your login.html.twig template or any other place you like

In our example code lines below we'll presume the our local webserver is reachable under . please change this domain by our development base server here.

further information about persona verifaction api can be found on

Please also refer to the official documentation of the SecurityBundle, especially for details on the configuration:

Prerequisites
=============

[](#prerequisites)

This version requires Symfony 2.1

Installation
============

[](#installation)

1 - Add the following lines in your composer.json:

```
{
    "require": {
        "bitgrave/persona-bundle": "dev-master"
    }
}

```

2 - Run the composer to download the bundle

```
    $ php composer.phar update bitgrave/persona-bundle

```

3 - Add this bundle to your application's kernel:

```
      // app/ApplicationKernel.php
      public function registerBundles()
      {
          return array(
              // ...
              new BG\PersonaBundle\BGPersonaBundle(),
              // ...
          );
      }

```

4 - Configure the `persona` service in your config:

```
  # application/config/config.yml
  bg_persona:
        verifier_url: 'https://verifier.login.persona.org/verify'
        audience_url: 'dev.example.com'

```

4.1. If you want to use `security component` add this configuration and define a custom user provider class, use it as provider or define login path (you can replace the given name my\_persona.persona\_provider by any other (distinct) one) ...

```
  # application/config/config.yml
  security:
        my_persona.persona_provider:
            id: my_persona.persona.user

  firewalls:
        main:
            bg_persona:
                default_target_path: /
                provider: my_persona.persona_provider
                login_path: /login
                check_path: /persona_login_check

```

5 - add routing for persona logincheck handler.

```
  # application/config/routing.yml
  _persona_security_check:
        pattern:   /persona_login_check

```

6 - (optional) add persona host-ident configuration inside your parameters.yml this step is not really necessary, you can place your host identification in config.yml (\_bg\_persona:)

```
  # application/config/parameters.yml
  webapp_url:         http://www.example.com
  webapp_url_ssl:     https://www.example.com

```

7 - place this dummy controller inside your LoginController file. this code presume you've sendio FrameworkExtraBundle installed and implemented (Route and Template module), if not setup person routing (/persona\_login\_check) inside your default routing.yml file.

```
/**
 * persona logincheck dummy controller.
 *
 * @Route("/persona_login_check")
 * @Template
 *
 * */
public function personaLoginCheckAction()
{
    return array();
}

```

Include the persona login button in your templates
--------------------------------------------------

[](#include-the-persona-login-button-in-your-templates)

add the following code in your login template (thats a twig sample for persona CSS3 button):

```

{{ persona_login_button() }}

```

Example Custom User Provider using the BG\\PersonaBundle
--------------------------------------------------------

[](#example-custom-user-provider-using-the-bgpersonabundle)

This requires adding a service for the custom user provider which is then set to the provider id in the "provider" section in the config.yml:

```
my_persona.persona.user:
    class: Nmq\UserBundle\Security\User\Provider\PersonaProvider
    arguments:
        persona: "@bg_persona.service"
        userManager: "@fos_user.user_manager"
        validator: "@validator"
        session: "@session"
        container: "@service_container"

```

The Custom User Provider Class:

```
