-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1066 from hyperunknown/csrf-ext-patch-1
Updated DisableCSRFExtension for 2.7+
- Loading branch information
Showing
5 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the FOSRestBundle 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\RestBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
|
||
class CsrfExtensionPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if($container->hasDefinition('fos_rest.form.extension.csrf_disable')) { | ||
$definition = $container->getDefinition('fos_rest.form.extension.csrf_disable'); | ||
|
||
if (interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) { | ||
$tokenStorageReference = new Reference('security.token_storage'); | ||
$definition->addArgument(new Reference('security.authorization_checker')); | ||
} else { | ||
$tokenStorageReference = new Reference('security.context'); | ||
} | ||
$definition->replaceArgument(0, $tokenStorageReference); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
use FOS\RestBundle\DependencyInjection\Compiler\ExceptionWrapperHandlerPass; | ||
use FOS\RestBundle\DependencyInjection\Compiler\FormatListenerRulesPass; | ||
use FOS\RestBundle\DependencyInjection\Compiler\TwigExceptionPass; | ||
use FOS\RestBundle\DependencyInjection\Compiler\CsrfExtensionPass; | ||
|
||
/** | ||
* @author Lukas Kahwe Smith <[email protected]> | ||
|
@@ -35,5 +36,6 @@ public function build(ContainerBuilder $container) | |
$container->addCompilerPass(new FormatListenerRulesPass()); | ||
$container->addCompilerPass(new TwigExceptionPass()); | ||
$container->addCompilerPass(new ExceptionWrapperHandlerPass()); | ||
$container->addCompilerPass(new CsrfExtensionPass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters