Skip to content

[Security] added AccessMapInterface #3374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private function createAuthorization($config, ContainerBuilder $container)
}

$this->addClassesToCompile(array(
'Symfony\\Component\\Security\\Http\\AccessMapInterface',
'Symfony\\Component\\Security\\Http\\AccessMap',
));

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/Http/AccessMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class AccessMap
class AccessMap implements AccessMapInterface
{
private $map = array();

Expand Down
33 changes: 33 additions & 0 deletions src/Symfony/Component/Security/Http/AccessMapInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Security\Http;

use Symfony\Component\HttpFoundation\Request;

/**
* AccessMap allows configuration of different access control rules for
* specific parts of the website.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Kris Wallsmith <kris@symfony.com>
*/
interface AccessMapInterface
{
/**
* Returns security attributes and required channel for the supplied request.
*
* @param Request $request The current request
*
* @return array A tuple of security attributes and the required channel
*/
function getPatterns(Request $request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand All @@ -33,7 +33,7 @@ class AccessListener implements ListenerInterface
private $authManager;
private $logger;

public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMap $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
public function __construct(SecurityContextInterface $context, AccessDecisionManagerInterface $accessDecisionManager, AccessMapInterface $map, AuthenticationManagerInterface $authManager, LoggerInterface $logger = null)
{
$this->context = $context;
$this->accessDecisionManager = $accessDecisionManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Security\Http\Firewall;

use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Http\AccessMapInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
Expand All @@ -28,7 +28,7 @@ class ChannelListener implements ListenerInterface
private $authenticationEntryPoint;
private $logger;

public function __construct(AccessMap $map, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
public function __construct(AccessMapInterface $map, AuthenticationEntryPointInterface $authenticationEntryPoint, LoggerInterface $logger = null)
{
$this->map = $map;
$this->authenticationEntryPoint = $authenticationEntryPoint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function testHandleWhenTheAccessDecisionManagerDecidesToRefuseAccess()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -64,7 +64,7 @@ public function testHandleWhenTheTokenIsNotAuthenticated()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -135,7 +135,7 @@ public function testHandleWhenThereIsNoAccessMapEntryMatchingTheRequest()
{
$request = $this->getMock('Symfony\Component\HttpFoundation\Request', array(), array(), '', false, false);

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -188,7 +188,7 @@ public function testHandleWhenTheSecurityContextHasNoToken()
$listener = new AccessListener(
$context,
$this->getMock('Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface'),
$this->getMock('Symfony\Component\Security\Http\AccessMap'),
$this->getMock('Symfony\Component\Security\Http\AccessMapInterface'),
$this->getMock('Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface')
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testHandleWithNotSecuredRequestAndHttpChannel()
->will($this->returnValue(false))
;

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -55,7 +55,7 @@ public function testHandleWithSecuredRequestAndHttpsChannel()
->will($this->returnValue(true))
;

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testHandleWithNotSecuredRequestAndHttpsChannel()

$response = new Response();

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down Expand Up @@ -138,7 +138,7 @@ public function testHandleWithSecuredRequestAndHttpChannel()

$response = new Response();

$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMap');
$accessMap = $this->getMock('Symfony\Component\Security\Http\AccessMapInterface');
$accessMap
->expects($this->any())
->method('getPatterns')
Expand Down