Skip to content

Commit d248556

Browse files
ghostikaGuilhemN
authored andcommitted
Cleanup
1 parent 3904bad commit d248556

File tree

5 files changed

+29
-4
lines changed

5 files changed

+29
-4
lines changed

Controller/AuthorizeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function authorizeAction(Request $request)
7979
}
8080

8181
/**
82-
* @param UserInterface $user
82+
* @param UserInterface $user
8383
* @param AuthorizeFormHandler $formHandler
8484
* @param Request $request
8585
*
@@ -127,7 +127,7 @@ protected function getRedirectionUrl(UserInterface $user)
127127
*/
128128
protected function getClient()
129129
{
130-
$request = $this->container->get('request_stack')->getMasterRequest();
130+
$request = $this->container->get('request_stack')->getCurrentRequest();
131131
if (null === $this->client) {
132132
if (null === $clientId = $request->get('client_id')) {
133133
$form = $this->container->get('fos_oauth_server.authorize.form');

DependencyInjection/Compiler/TokenStorageCompilerPass.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<?php
22

3+
/*
4+
* This file is part of the FOSOAuthServerBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
312
namespace FOS\OAuthServerBundle\DependencyInjection\Compiler;
413

514
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@@ -18,7 +27,7 @@ public function process(ContainerBuilder $container)
1827
{
1928
$definition = $container->getDefinition('fos_oauth_server.security.authentication.listener');
2029

21-
if (interface_exists('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')) {
30+
if ($container->hasDefinition('security.token_storage')) {
2231
$tokenStorageReference = new Reference('security.token_storage');
2332
} else {
2433
$tokenStorageReference = new Reference('security.context');

Form/Handler/AuthorizeFormHandler.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ class AuthorizeFormHandler
2424
protected $request;
2525
protected $form;
2626

27+
/**
28+
* @var RequestStack
29+
*/
30+
private $requestStack;
31+
2732
public function __construct(FormInterface $form, RequestStack $requestStack)
2833
{
2934
$this->form = $form;
30-
$this->request = $requestStack->getMasterRequest();
35+
$this->requestStack = $requestStack;
3136
}
3237

3338
public function isAccepted()
@@ -42,6 +47,8 @@ public function isRejected()
4247

4348
public function process()
4449
{
50+
$this->request = $this->requestStack->getCurrentRequest();
51+
4552
$this->form->setData(new Authorize(
4653
$this->request->request->has('accepted'),
4754
$this->request->query->all()

Security/Firewall/OAuthListener.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class OAuthListener implements ListenerInterface
5151
*/
5252
public function __construct($securityContext, AuthenticationManagerInterface $authenticationManager, OAuth2 $serverService)
5353
{
54+
if (!$securityContext instanceof TokenStorageInterface && !$securityContext instanceof SecurityContextInterface) {
55+
throw new \InvalidArgumentException('Wrong type for OAuthListener, it has to implement TokenStorageInterface or SecurityContextInterface');
56+
}
5457
$this->securityContext = $securityContext;
5558
$this->authenticationManager = $authenticationManager;
5659
$this->serverService = $serverService;

Tests/Security/Firewall/OAuthListenerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,10 @@ public function testHandleResponse()
103103
$this->assertEquals($response, $ret);
104104
}
105105

106+
public function testWrongTypeForOAuthListener()
107+
{
108+
$this->setExpectedException('InvalidArgumentException');
109+
$listener = new OAuthListener($this->event, $this->authManager, $this->serverService);
110+
}
111+
106112
}

0 commit comments

Comments
 (0)