2017 © Pedro Peláez
 

library opauth-fosub-bundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

image

damianociarla/opauth-fosub-bundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  • Friday, November 14, 2014
  • by damianociarla
  • Repository
  • 1 Watchers
  • 5 Stars
  • 64 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication., (*1)

This bundle uses an Entity, related to the FOS user table, to store the user's data retrieved by the authentication service., (*2)

This bundle does not modify the FOSUserBundle login/registration but allows the user to synchronize with providers enabled by the application., (*3)

Prerequisites

To use DCSOpauthFOSUBBundle you need to download, install and configure DCSOpauthBundle and FOSUserBundle., (*4)

For specific documentation refer to the documentation of the individual bundles, (*5)

Installation

a) Download and install DCSOpauthFOSUBBundle

To install DCSOpauthBundle run the following command, (*6)

bash $ php composer.phar require damianociarla/opauth-fosub-bundle

b) Enable the bundle

To enable it add the bundle instance in the kernel:, (*7)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new DCS\OpauthFOSUBBundle\DCSOpauthFOSUBBundle(),
    );
}

c) Create your Oauth classes

In this first release DCSOpauthFOSUBBundle supports only Doctrine ORM. You must provide a concrete Oauth class. You must extend the abstract entity provided by the bundle and create the appropriate mapping., (*8)

Annotations

src/Acme/OpauthFOSUBBundle/Entity/Oauth.php, (*9)

<?php

namespace Acme\OpauthFOSUBBundle\Entity;

use DCS\OpauthFOSUBBundle\Entity\Oauth as BaseOauth;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="fos_user_oauth")
 */
class Oauth extends BaseOauth
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\ManyToOne(targetEntity="Acme\UserBundle\Entity\User")
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable="false")
     */
    protected $user;

    public function __construct()
    {
        parent::__construct();
        // your own logic
    }
}

xml

If you use xml to configure Doctrine you must add two files. The Entity and the orm.xml:, (*10)

src/Acme/OpauthFOSUBBundle/Entity/Oauth.php, (*11)

<?php

namespace Acme\OpauthFOSUBBundle\Entity;

use DCS\OpauthFOSUBBundle\Entity\Oauth as BaseOauth;

class Oauth extends BaseOauth
{
}

src/Acme/OpauthFOSUBBundle/Resources/config/doctrine/Oauth.orm.yml, (*12)

<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

    <entity name="Acme\OpauthFOSUBBundle\Entity\Oauth" table="fos_user_oauth">

        <id name="id" type="integer" column="id">
            <generator strategy="AUTO" />
        </id>

        <many-to-one field="user" target-entity="Acme\UserBundle\Entity\User">
            <join-column name="user_id" referenced-column-name="id" nullable="false" />
        </many-to-one>

    </entity>

</doctrine-mapping>

d) Configure the bundle

Now that you have properly enabled and configured the DCSOpauthFOSUBBundle, the next step is to configure the bundle to work with the specific needs of your application., (*13)

Add the following configuration to your config.yml file., (*14)

# app/config/config.yml

dcs_opauth_fosub:
    oauth_model: Acme\OpauthFOSUBBundle\Entity\Oauth

How does it work?

DCSOpauthFOSUBBundle doesn't change the FOSUserBundle registration flow but adds the possibility to synchronize and register using external authentication providers (Facebook, Google, LinkedIn) using the connect route provided by DCSOpauth., (*15)

If the user is not authenticated, after authenticating with DCSOpauthBundle, DCSOpauthFOSUBBundle checks if a user with that UID exists, if it does exist the user gets logged-in, if it does not exist, the FOSUserBundle registration form is opened. At the end of the FOSUserBundle registration a record with the provider name and UID is created and associated with the new user., (*16)

If the user is already authenticated, after authenticating with DCSOpauthBundle, DCSOpauthFOSUBBundle associates the logged-in user with the UID and provider name., (*17)

The Versions

14/11 2014

dev-master

9999999-dev https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

14/11 2014

v1.0.7

1.0.7.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

12/11 2014

v1.0.6

1.0.6.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

12/11 2014

v1.0.5

1.0.5.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

11/11 2014

v1.0.4

1.0.4.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

11/11 2014

v1.0.3

1.0.3.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

23/08 2014

v1.0.2

1.0.2.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

04/08 2014

v1.0.1

1.0.1.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle

28/05 2014

v1.0

1.0.0.0 https://github.com/damianociarla/DCSOpauthFOSUBBundle

DCSOpauthFOSUBBundle is a Symfony2 bundle that integrates DCSOpauthBundle with FOSUserBundle and allows users to login/register to your site using third party authentication

  Sources   Download

MIT

The Requires

 

framework oauth opauth symfony2 oauth2 fos fosuserbundle sync dcsopauthbundle