Skip to content

Commit

Permalink
Started to work on FOSOAuthServerBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Dec 16, 2011
1 parent 5b54858 commit efc8129
Show file tree
Hide file tree
Showing 55 changed files with 355 additions and 285 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Tests/autoload.php
vendor/bundles/Alb/OAuth2ServerBundle
vendor/
18 changes: 14 additions & 4 deletions Controller/ServerController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?php

namespace Alb\OAuth2ServerBundle\Controller;
/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\OAuthServerBundle\Controller;

use OAuth2\OAuth2;
use Symfony\Component\HttpFoundation\Request;
use OAuth2\OAuth2ServerException;

use Symfony\Component\HttpFoundation\Request;

class ServerController
{
protected $request;

protected $serverService;

public function __construct(Request $request, OAuth2 $serverService)
Expand All @@ -20,8 +31,7 @@ public function __construct(Request $request, OAuth2 $serverService)
public function tokenAction()
{
try {
$response = $this->serverService->grantAccessToken($this->request);
return $response;
return $this->serverService->grantAccessToken($this->request);
} catch(OAuth2ServerException $e) {
return $e->getHttpResponse();
}
Expand Down
25 changes: 17 additions & 8 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?php

namespace Alb\OAuth2ServerBundle\DependencyInjection;
/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\OAuthServerBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

/**
* This is the class that validates and merges configuration from your app/config files
Expand All @@ -19,17 +28,17 @@ class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('alb_o_auth2_server');
$rootNode = $treeBuilder->root('fos_o_auth_server');

$rootNode
->children()
->scalarNode('db_driver')->cannotBeOverwritten()->isRequired()->cannotBeEmpty()->end()
->scalarNode('storage_service')->defaultValue('alb.oauth2.server.server_service.storage.default')->cannotBeEmpty()->end()
->scalarNode('storage_service')->defaultValue('fos.oauth_server.server_service.storage.default')->cannotBeEmpty()->end()
->scalarNode('user_provider_service')->end()
->scalarNode('oauth2_client_class')->isRequired()->cannotBeEmpty()->end()
->scalarNode('oauth2_access_token_class')->isRequired()->cannotBeEmpty()->end()
->scalarNode('oauth2_auth_code_class')->isRequired()->cannotBeEmpty()->end()
->arrayNode('oauth2_options')
->scalarNode('oauth_client_class')->isRequired()->cannotBeEmpty()->end()
->scalarNode('oauth_access_token_class')->isRequired()->cannotBeEmpty()->end()
->scalarNode('oauth_auth_code_class')->isRequired()->cannotBeEmpty()->end()
->arrayNode('oauth_options')
->useAttributeAsKey('key')
->treatNullLike(array())
->prototype('scalar')->end()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<?php

namespace Alb\OAuth2ServerBundle\DependencyInjection;
/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Component\DependencyInjection\ContainerBuilder;
namespace FOS\OAuthServerBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* This is the class that loads and manages your bundle configuration
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class AlbOAuth2ServerExtension extends Extension
class FOSOAuthServerExtension extends Extension
{
/**
* {@inheritDoc}
Expand All @@ -36,20 +45,19 @@ public function load(array $configs, ContainerBuilder $container)

if ($config['storage_service']) {
$container
->setAlias('alb.oauth2.server.server_service.storage', $config['storage_service']);
->setAlias('fos.oauth_server.server_service.storage', $config['storage_service']);
}

if (isset($config['user_provider_service'])) {
$container
->getDefinition('alb.oauth2.server.server_service.storage.default')
->getDefinition('fos.oauth_server.server_service.storage.default')
->replaceArgument(3, new Reference($config['user_provider_service']))
;
}

$container->setParameter('alb.oauth2.server.model.client.class', $config['oauth2_client_class']);
$container->setParameter('alb.oauth2.server.model.access.token.class', $config['oauth2_access_token_class']);
$container->setParameter('alb.oauth2.server.model.auth.code.class', $config['oauth2_auth_code_class']);

$container->setParameter('alb.oauth2.server.server_service.options', $config['oauth2_options']);
$container->setParameter('fos.oauth_server.model.client.class', $config['oauth2_client_class']);
$container->setParameter('fos.oauth_server.model.access.token.class', $config['oauth2_access_token_class']);
$container->setParameter('fos.oauth_server.model.auth.code.class', $config['oauth2_auth_code_class']);
$container->setParameter('fos.oauth_server.server_service.options', $config['oauth2_options']);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php

namespace Alb\OAuth2ServerBundle\DependencyInjection\Security\Factory;
/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\OAuthServerBundle\DependencyInjection\Security\Factory;

use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
Expand All @@ -9,29 +18,27 @@
use Symfony\Component\DependencyInjection\Reference;

/**
* OAuth2Factory class.
* OAuthFactory class.
*
* @package AlbOAuth2ServerBundle
* @subpackage DependencyInjection
* @author Arnaud Le Blanc <[email protected]>
*/
class OAuth2Factory implements SecurityFactoryInterface
class OAuthFactory implements SecurityFactoryInterface
{
/**
* {@inheritdoc}
*/
public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint)
{
$providerId = 'security.authentication.provider.alb_oauth2_server.'.$id;
$providerId = 'security.authentication.provider.fos_oauth_server.'.$id;
$container
->setDefinition($providerId, new DefinitionDecorator('alb.oauth2.server.security.authentication.provider'))
->setDefinition($providerId, new DefinitionDecorator('fos.oauth_server.security.authentication.provider'))
->replaceArgument(0, new Reference($userProvider))
;

$listenerId = 'security.authentication.listener.alb_oauth2_server.'.$id;
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('alb.oauth2.server.security.authentication.listener'));
$listenerId = 'security.authentication.listener.fos_oauth_server.'.$id;
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('fos.oauth_server.security.authentication.listener'));

return array($providerId, $listenerId, 'alb.oauth2.server.security.entry_point');
return array($providerId, $listenerId, 'fos.oauth_server.security.entry_point');
}

/**
Expand All @@ -47,7 +54,7 @@ public function getPosition()
*/
public function getKey()
{
return 'alb_oauth2';
return 'fos_oauth';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Document/OAuth2AccessToken.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2AccessToken as BaseOAuth2AccessToken;
use FOS\OAuthServerBundle\Model\OAuth2AccessToken as BaseOAuth2AccessToken;

class OAuth2AccessToken extends BaseOAuth2AccessToken
{
Expand Down
6 changes: 3 additions & 3 deletions Document/OAuth2AccessTokenManager.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Document\OAuth2TokenManager;
use Alb\OAuth2ServerBundle\Model\OAuth2AccessTokenManagerInterface;
use FOS\OAuthServerBundle\Document\OAuth2TokenManager;
use FOS\OAuthServerBundle\Model\OAuth2AccessTokenManagerInterface;

class OAuth2AccessTokenManager extends OAuth2TokenManager implements OAuth2AccessTokenManagerInterface
{
Expand Down
4 changes: 2 additions & 2 deletions Document/OAuth2AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
*/

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2AuthCode as BaseOAuth2AuthCode;
use FOS\OAuthServerBundle\Model\OAuth2AuthCode as BaseOAuth2AuthCode;

/**
* @author Richard Fullmer <[email protected]>
Expand Down
6 changes: 3 additions & 3 deletions Document/OAuth2AuthCodeManager.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2AuthCodeManager as BaseOAuth2AuthCodeManager;
use Alb\OAuth2ServerBundle\Model\OAuth2AuthCodeInterface;
use FOS\OAuthServerBundle\Model\OAuth2AuthCodeManager as BaseOAuth2AuthCodeManager;
use FOS\OAuthServerBundle\Model\OAuth2AuthCodeInterface;
use Doctrine\ODM\MongoDB\DocumentManager;

class OAuth2AuthCodeManager extends BaseOAuth2AuthCodeManager
Expand Down
4 changes: 2 additions & 2 deletions Document/OAuth2Client.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2Client as BaseOAuth2Client;
use FOS\OAuthServerBundle\Model\OAuth2Client as BaseOAuth2Client;

class OAuth2Client extends BaseOAuth2Client
{
Expand Down
6 changes: 3 additions & 3 deletions Document/OAuth2ClientManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2ClientManager as BaseOAuth2ClientManager;
use FOS\OAuthServerBundle\Model\OAuth2ClientManager as BaseOAuth2ClientManager;
use Doctrine\ODM\MongoDB\DocumentManager;
use Alb\OAuth2ServerBundle\Model\OAuth2ClientInterface;
use FOS\OAuthServerBundle\Model\OAuth2ClientInterface;

class OAuth2ClientManager extends BaseOAuth2ClientManager
{
Expand Down
6 changes: 3 additions & 3 deletions Document/OAuth2TokenManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Alb\OAuth2ServerBundle\Document;
namespace FOS\OAuthServerBundle\Document;

use Alb\OAuth2ServerBundle\Model\OAuth2TokenManager as BaseOAuth2TokenManager;
use FOS\OAuthServerBundle\Model\OAuth2TokenManager as BaseOAuth2TokenManager;
use Doctrine\ODM\MongoDB\DocumentManager;
use Alb\OAuth2ServerBundle\Model\OAuth2TokenInterface;
use FOS\OAuthServerBundle\Model\OAuth2TokenInterface;

class OAuth2TokenManager extends BaseOAuth2TokenManager
{
Expand Down
4 changes: 2 additions & 2 deletions Entity/OAuth2AccessToken.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Model\OAuth2AccessToken as BaseOAuth2AccessToken;
use FOS\OAuthServerBundle\Model\OAuth2AccessToken as BaseOAuth2AccessToken;

class OAuth2AccessToken extends BaseOAuth2AccessToken
{
Expand Down
6 changes: 3 additions & 3 deletions Entity/OAuth2AccessTokenManager.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Entity\OAuth2TokenManager;
use Alb\OAuth2ServerBundle\Model\OAuth2AccessTokenManagerInterface;
use FOS\OAuthServerBundle\Entity\OAuth2TokenManager;
use FOS\OAuthServerBundle\Model\OAuth2AccessTokenManagerInterface;

class OAuth2AccessTokenManager extends OAuth2TokenManager implements OAuth2AccessTokenManagerInterface
{
Expand Down
4 changes: 2 additions & 2 deletions Entity/OAuth2AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
*/

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Model\OAuth2AuthCode as BaseOAuth2AuthCode;
use FOS\OAuthServerBundle\Model\OAuth2AuthCode as BaseOAuth2AuthCode;

/**
* @author Richard Fullmer <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions Entity/OAuth2AuthCodeManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Entity\OAuth2TokenManager;
use Alb\OAuth2ServerBundle\Model\OAuth2AuthCodeManager as BaseOAuth2AuthCodeManager;
use Alb\OAuth2ServerBundle\Model\OAuth2AuthCodeInterface;
use FOS\OAuthServerBundle\Entity\OAuth2TokenManager;
use FOS\OAuthServerBundle\Model\OAuth2AuthCodeManager as BaseOAuth2AuthCodeManager;
use FOS\OAuthServerBundle\Model\OAuth2AuthCodeInterface;
use Doctrine\ORM\EntityManager;

class OAuth2AuthCodeManager extends BaseOAuth2AuthCodeManager
Expand Down
4 changes: 2 additions & 2 deletions Entity/OAuth2Client.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Model\OAuth2Client as BaseOAuth2Client;
use FOS\OAuthServerBundle\Model\OAuth2Client as BaseOAuth2Client;

class OAuth2Client extends BaseOAuth2Client
{
Expand Down
6 changes: 3 additions & 3 deletions Entity/OAuth2ClientManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Model\OAuth2ClientManager as BaseOAuth2ClientManager;
use FOS\OAuthServerBundle\Model\OAuth2ClientManager as BaseOAuth2ClientManager;
use Doctrine\ORM\EntityManager;
use Alb\OAuth2ServerBundle\Model\OAuth2ClientInterface;
use FOS\OAuthServerBundle\Model\OAuth2ClientInterface;

class OAuth2ClientManager extends BaseOAuth2ClientManager
{
Expand Down
6 changes: 3 additions & 3 deletions Entity/OAuth2TokenManager.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Alb\OAuth2ServerBundle\Entity;
namespace FOS\OAuthServerBundle\Entity;

use Alb\OAuth2ServerBundle\Model\OAuth2TokenManager as BaseOAuth2TokenManager;
use FOS\OAuthServerBundle\Model\OAuth2TokenManager as BaseOAuth2TokenManager;
use Doctrine\ORM\EntityManager;
use Alb\OAuth2ServerBundle\Model\OAuth2TokenInterface;
use FOS\OAuthServerBundle\Model\OAuth2TokenInterface;

class OAuth2TokenManager extends BaseOAuth2TokenManager
{
Expand Down
Loading

0 comments on commit efc8129

Please sign in to comment.