2017 © Pedro Peláez
 

symfony2-bundle oauth-extension-bundle

OAuth Extension for FOSOAuthServerBundle

image

vss/oauth-extension-bundle

OAuth Extension for FOSOAuthServerBundle

  • Tuesday, February 14, 2017
  • by NathanVss
  • Repository
  • 1 Watchers
  • 1 Stars
  • 218 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

VssOAuthExtensionBundle

Build Status, (*1)

codecov.io, (*2)

Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Documentation

Introduction

This bundle extends the features of the friendsofsymfony/oauth-server-bundle ( https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Resources/doc/index.md )., (*4)

Grants

Email Grant

This grant allow email based token delivering, the first argument must be a self-made class implementing the interface Vss\OAuthExtensionBundle\Security\Utils\EmailProvider. This class is responsible to deliver a user ( Symfony\Component\Security\Core\User\UserInterface) or null., (*5)

  oauth.grant.email:
      class: Vss\OAuthExtensionBundle\Grant\EmailGrant
      arguments:
          - "@app.security.provider.client_email"
          - "@security.encoder_factory"
      tags:
            - { name: fos_oauth_server.grant_extension, uri: 'http://mplatform.com/grants/email' }

Here is the @app.security.provider.client_emailservice, Client implements UserInterface., (*6)

``` php namespace AppBundle\Security\Client;, (*7)

use AppBundle\Entity\Client; use AppBundle\Entity\PlayerRepository; use Doctrine\ORM\EntityManagerInterface; use Vss\OAuthExtensionBundle\Security\Utils\EmailProvider;, (*8)

/** * Class ClientEmailProvider * @package AppBundle\Security */ class ClientEmailProvider implements EmailProvider {, (*9)

/**
 * @var \Doctrine\Common\Persistence\ObjectRepository
 */
private $rep;

/**
 * ClientEmailProvider constructor.
 * @param EntityManagerInterface $em
 */
public function __construct(EntityManagerInterface $em) {
    $this->rep = $em->getRepository('AppBundle:Client');
}

/**
 * @inheritdoc
 */
public function loadByEmail($email){
    return $this->rep->findOneBy(['email' => $email]);
}

}, (*10)


The idea is that you can setup multiple grants for differents user types, we can imagine one EmailProvider returning Admin, an other returning a User, Moderator, etc ... So it is very flexible. #### Provider Grant This grant is supposed to deliver a token from a OAuth Login, like Facebook Login. ``` yaml oauth.grant.provider: class: Vss\OAuthExtensionBundle\Grant\ProviderGrant arguments: ["@vss_oauth_extension.oauth_manager", "@app.security.client_manager"] tags: - { name: fos_oauth_server.grant_extension, uri: 'http://mplatform.com/grants/provider' }

The second argument implement the interface Vss\OAuthExtensionBundle\Security\OAuth\OAuthUserManagerInterface. Then, this manage should return a user with the provider id or email for example. This grant works with OAuth Authorization Code or OAuth Access Token from the provider. If it is possible I would recommend using the Code instead of Access Token if your website doesn't support HTTPS., (*11)

Now, only these providers are available : - Facebook, (*12)

Example configuration from config.yml., (*13)

``` yaml vss_oauth_extension:, (*14)

providers:
    facebook:
        type: facebook
        client_id: 1746857792272443
        client_secret: cf395620ca4e0622af55c6d709148f72

```, (*15)

TODOS

Improve doc, more tests., (*16)

The Versions

14/02 2017

dev-master

9999999-dev

OAuth Extension for FOSOAuthServerBundle

  Sources   Download

MIT

The Requires

 

by Nathan

14/02 2017

v1.0.2

1.0.2.0

OAuth Extension for FOSOAuthServerBundle

  Sources   Download

MIT

The Requires

 

by Nathan

26/12 2016

v1.0.1

1.0.1.0

OAuth Extension for FOSOAuthServerBundle

  Sources   Download

MIT

The Requires

 

by Nathan

26/12 2016

v1.0.0

1.0.0.0

OAuth Extension for FOSOAuthServerBundle

  Sources   Download

MIT

The Requires

 

by Nathan

22/07 2016
18/05 2016
10/04 2016
05/04 2016
06/03 2016
21/02 2016
07/02 2016

0.0.1

0.0.1.0

OAuth Extension for FOSOAuthServerBundle

  Sources   Download

MIT

The Requires

 

by Nathan