Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

fix firewall to answer all login entry points #158

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b3c1b81
fixing firewall only response to the entry point if there is a query …
bitgandtter Jul 4, 2012
960144f
upgrading to 2.1
bitgandtter Aug 5, 2012
e8592be
allowing only facebook autentication request
bitgandtter Oct 9, 2012
2bb79b2
updating composer
bitgandtter Mar 5, 2013
52c3e30
updating composer
bitgandtter May 13, 2013
ddd7dc9
updating composer
bitgandtter May 14, 2013
9ea56a2
returning all facebook data
bitgandtter May 20, 2013
ddaecfe
adding trigger login twig function
bitgandtter May 20, 2013
bbcee1a
adding trigger login twig function
bitgandtter May 21, 2013
a60984d
adding trigger login twig function
bitgandtter May 21, 2013
60fe221
adding trigger login twig function
bitgandtter May 21, 2013
11d6601
fixing error of throwing AuthError
bitgandtter May 21, 2013
fd5c2ab
updating trigger login code
bitgandtter May 21, 2013
9713022
updating trigger login code
bitgandtter May 22, 2013
8dfa8e6
adding option to include only code on template functions
bitgandtter May 23, 2013
aa52fe7
adding option to include only code on template functions
bitgandtter May 23, 2013
31245da
updating composer
bitgandtter May 26, 2013
fd50583
updating composer
bitgandtter May 26, 2013
83e18cf
updating new functions
bitgandtter May 27, 2013
1866e7a
adding new login js function
bitgandtter Jun 2, 2013
59fc221
adding oauth popup library
bitgandtter Jun 3, 2013
96c103e
fixing new funciton
bitgandtter Jun 3, 2013
266a139
reverting change forcing to include this jquery plugin
bitgandtter Jun 3, 2013
1c66720
adding function to handle unauthorized
bitgandtter Jun 6, 2013
ef67b3b
fixing error on login function
bitgandtter Jun 7, 2013
0e9aa57
updating js login funciton
bitgandtter Jun 7, 2013
de9fda3
updating js login funciton
bitgandtter Jun 7, 2013
4830012
updating js login funciton
bitgandtter Jun 7, 2013
fe0743e
updating js login funciton
bitgandtter Jun 7, 2013
940f752
cleaning files to prepare migration to BIT namespace
bitgandtter Jul 2, 2013
7fd5f19
Merge branch 'master' of github.com:bitgandtter/FOSFacebookBundle
bitgandtter Jul 2, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Controller/AuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace FOS\FacebookBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;

class AuthController extends Controller
{

public function writeAuthInSessionAction( )
{
$accessToken = $this->getRequest( )->get( "accessToken" );
$this->get( "session" )->set( "fb.accessToken", $accessToken );
return new JsonResponse( array( "accessToken" => $accessToken ));
}
}
62 changes: 25 additions & 37 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
*/

namespace FOS\FacebookBundle\DependencyInjection;

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

/**
* This class contains the configuration information for the bundle
Expand All @@ -24,38 +22,28 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* Generates the configuration tree.
*
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('fos_facebook');

$rootNode
->fixXmlConfig('permission', 'permissions')
->children()
->scalarNode('app_id')->isRequired()->cannotBeEmpty()->end()
->scalarNode('secret')->isRequired()->cannotBeEmpty()->end()
->scalarNode('file')->defaultNull()->end()
->scalarNode('cookie')->defaultFalse()->end()
->scalarNode('domain')->defaultNull()->end()
->scalarNode('alias')->defaultNull()->end()
->scalarNode('logging')->defaultValue('%kernel.debug%')->end()
->scalarNode('culture')->defaultValue('en_US')->end()
->arrayNode('class')
->addDefaultsIfNotSet()
->children()
->scalarNode('api')->defaultValue('FOS\FacebookBundle\Facebook\FacebookSessionPersistence')->end()
->scalarNode('helper')->defaultValue('FOS\FacebookBundle\Templating\Helper\FacebookHelper')->end()
->scalarNode('twig')->defaultValue('FOS\FacebookBundle\Twig\Extension\FacebookExtension')->end()
->end()
->end()
->arrayNode('permissions')->prototype('scalar')->end()
->end();

return $treeBuilder;
}
/**
* Generates the configuration tree.
*
* @return TreeBuilder
*/

public function getConfigTreeBuilder( )
{
$treeBuilder = new TreeBuilder( );
$rootNode = $treeBuilder->root( 'fos_facebook' );

$rootNode->fixXmlConfig( 'permission', 'permissions' )->children( )->scalarNode( 'app_id' )->isRequired( )
->cannotBeEmpty( )->end( )->scalarNode( 'secret' )->isRequired( )->cannotBeEmpty( )->end( )->scalarNode( 'file' )
->defaultNull( )->end( )->scalarNode( 'cookie' )->defaultFalse( )->end( )->scalarNode( 'domain' )
->defaultNull( )->end( )->scalarNode( 'alias' )->defaultNull( )->end( )->scalarNode( 'logging' )
->defaultValue( '%kernel.debug%' )->end( )->scalarNode( 'culture' )->defaultValue( 'en_US' )->end( )
->arrayNode( 'class' )->addDefaultsIfNotSet( )->children( )->scalarNode( 'api' )
->defaultValue( 'FOS\FacebookBundle\Facebook\FacebookSessionPersistence' )->end( )->scalarNode( 'helper' )
->defaultValue( 'FOS\FacebookBundle\Templating\Helper\FacebookHelper' )->end( )->scalarNode( 'twig' )
->defaultValue( 'FOS\FacebookBundle\Twig\Extension\FacebookExtension' )->end( )->end( )->end( )
->arrayNode( 'permissions' )->prototype( 'scalar' )->end( )->end( );

return $treeBuilder;
}
}
106 changes: 55 additions & 51 deletions DependencyInjection/FOSFacebookExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/

namespace FOS\FacebookBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
Expand All @@ -19,62 +18,67 @@

class FOSFacebookExtension extends Extension
{
protected $resources = array(
'facebook' => 'facebook.xml',
'security' => 'security.xml',
);

public function load(array $configs, ContainerBuilder $container)
protected $resources = array( 'facebook' => 'facebook.xml', 'security' => 'security.xml', );

public function load( array $configs, ContainerBuilder $container )
{
$processor = new Processor( );
$configuration = new Configuration( );
$config = $processor->processConfiguration( $configuration, $configs );

$this->loadDefaults( $container );

if ( isset( $config[ 'alias' ] ) )
{
$processor = new Processor();
$configuration = new Configuration();
$config = $processor->processConfiguration($configuration, $configs);

$this->loadDefaults($container);

if (isset($config['alias'])) {
$container->setAlias($config['alias'], 'fos_facebook.api');
}

foreach (array('api', 'helper', 'twig') as $attribute) {
$container->setParameter('fos_facebook.'.$attribute.'.class', $config['class'][$attribute]);
}

foreach (array('app_id', 'secret', 'cookie', 'domain', 'logging', 'culture', 'permissions') as $attribute) {
$container->setParameter('fos_facebook.'.$attribute, $config[$attribute]);
}

if (isset($config['file']) && $container->hasDefinition('fos_facebook.api')) {
$facebookApi = $container->getDefinition('fos_facebook.api');
$facebookApi->setFile($config['file']);
}
$container->setAlias( $config[ 'alias' ], 'fos_facebook.api' );
}

/**
* @codeCoverageIgnore
*/
public function getXsdValidationBasePath()

foreach ( array( 'api', 'helper', 'twig' ) as $attribute )
{
return __DIR__ . '/../Resources/config/schema';
$container->setParameter( 'fos_facebook.' . $attribute . '.class', $config[ 'class' ][ $attribute ] );
}

/**
* @codeCoverageIgnore
*/
public function getNamespace()

foreach ( array( 'app_id', 'secret', 'cookie', 'domain', 'logging', 'culture', 'permissions' ) as $attribute )
{
return 'http://symfony.com/schema/dic/fos_facebook';
$container->setParameter( 'fos_facebook.' . $attribute, $config[ $attribute ] );
}

/**
* @codeCoverageIgnore
*/
protected function loadDefaults($container)

if ( isset( $config[ 'file' ] ) && $container->hasDefinition( 'fos_facebook.api' ) )
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

foreach ($this->resources as $resource) {
$loader->load($resource);
}
$facebookApi = $container->getDefinition( 'fos_facebook.api' );
$facebookApi->setFile( $config[ 'file' ] );
}
}

/**
* @codeCoverageIgnore
*/

public function getXsdValidationBasePath( )
{
return __DIR__ . '/../Resources/config/schema';
}

/**
* @codeCoverageIgnore
*/

public function getNamespace( )
{
return 'http://symfony.com/schema/dic/fos_facebook';
}

/**
* @codeCoverageIgnore
*/

protected function loadDefaults( $container )
{
$loader = new XmlFileLoader( $container, new FileLocator( __DIR__ . '/../Resources/config'));

foreach ( $this->resources as $resource )
{
$loader->load( $resource );
}
}
}
105 changes: 51 additions & 54 deletions DependencyInjection/Security/Factory/FacebookFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,57 @@

class FacebookFactory extends AbstractFactory
{
public function __construct()

public function __construct( )
{
$this->addOption( 'display', 'page' );
$this->addOption( 'app_url' );
$this->addOption( 'server_url' );
$this->addOption( 'create_user_if_not_exists', false );
}

public function getPosition( )
{
return 'pre_auth';
}

public function getKey( )
{
return 'fos_facebook';
}

protected function getListenerId( )
{
return 'fos_facebook.security.authentication.listener';
}

protected function createAuthProvider( ContainerBuilder $container, $id, $config, $userProviderId )
{
$authProviderId = 'fos_facebook.auth.' . $id;

$definition = $container->setDefinition( $authProviderId, new DefinitionDecorator( 'fos_facebook.auth') )
->replaceArgument( 0, $id );

// with user provider
if ( isset( $config[ 'provider' ] ) )
{
$this->addOption('display', 'page');
$this->addOption('app_url');
$this->addOption('server_url');
$this->addOption('create_user_if_not_exists', false);
}

public function getPosition()
{
return 'pre_auth';
}

public function getKey()
{
return 'fos_facebook';
}

protected function getListenerId()
{
return 'fos_facebook.security.authentication.listener';
}

protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId)
{
$authProviderId = 'fos_facebook.auth.'.$id;

$definition = $container
->setDefinition($authProviderId, new DefinitionDecorator('fos_facebook.auth'))
->replaceArgument(0, $id);

// with user provider
if (isset($config['provider'])) {
$definition
->addArgument(new Reference($userProviderId))
->addArgument(new Reference('security.user_checker'))
->addArgument($config['create_user_if_not_exists'])
;
}

return $authProviderId;
}

protected function createEntryPoint($container, $id, $config, $defaultEntryPointId)
{
$entryPointId = 'fos_facebook.security.authentication.entry_point.'.$id;
$container
->setDefinition($entryPointId, new DefinitionDecorator('fos_facebook.security.authentication.entry_point'))
->replaceArgument(1, $config)
;

// set options to container for use by other classes
$container->setParameter('fos_facebook.options.'.$id, $config);

return $entryPointId;
$definition->addArgument( new Reference( $userProviderId) )->addArgument( new Reference( 'security.user_checker') )
->addArgument( $config[ 'create_user_if_not_exists' ] );
}

return $authProviderId;
}

protected function createEntryPoint( $container, $id, $config, $defaultEntryPointId )
{
$entryPointId = 'fos_facebook.security.authentication.entry_point.' . $id;
$container
->setDefinition( $entryPointId, new DefinitionDecorator( 'fos_facebook.security.authentication.entry_point') )
->replaceArgument( 1, $config );

// set options to container for use by other classes
$container->setParameter( 'fos_facebook.options.' . $id, $config );

return $entryPointId;
}
}
16 changes: 8 additions & 8 deletions FOSFacebookBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
*/

namespace FOS\FacebookBundle;

use FOS\FacebookBundle\DependencyInjection\Security\Factory\FacebookFactory;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class FOSFacebookBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);

$extension = $container->getExtension('security');
$extension->addSecurityListenerFactory(new FacebookFactory());
}

public function build( ContainerBuilder $container )
{
parent::build( $container );

$extension = $container->getExtension( 'security' );
$extension->addSecurityListenerFactory( new FacebookFactory( ) );
}
}
Loading