summaryrefslogtreecommitdiffstats
path: root/SecurityContext.php
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2011-01-25 20:28:26 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-01-26 16:38:54 +0100
commit521c9f65e9d70618f63ac6ed803a495651b9fd35 (patch)
tree4e64bf3f877a4050eb3eb95c0b55630a4105053c /SecurityContext.php
parentbff922f5c7ab61fb144e124b584da067842cb955 (diff)
downloadsymfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.zip
symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.gz
symfony-security-521c9f65e9d70618f63ac6ed803a495651b9fd35.tar.bz2
[Security] many improvements, and fixes
Diffstat (limited to 'SecurityContext.php')
-rw-r--r--SecurityContext.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/SecurityContext.php b/SecurityContext.php
index e694d82..bf6324a 100644
--- a/SecurityContext.php
+++ b/SecurityContext.php
@@ -11,8 +11,9 @@
namespace Symfony\Component\Security;
+use Symfony\Component\Security\Authorization\AccessDecisionManagerInterface;
+use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Authentication\Token\TokenInterface;
-use Symfony\Component\Security\Authorization\AccessDecisionManager;
use Symfony\Component\Security\Acl\Voter\FieldVote;
/**
@@ -30,15 +31,19 @@ class SecurityContext
protected $token;
protected $accessDecisionManager;
+ protected $authenticationManager;
+ protected $alwaysAuthenticate;
/**
* Constructor.
*
- * @param AccessDecisionManager|null $accessDecisionManager An AccessDecisionManager instance
+ * @param AccessDecisionManagerInterface|null $accessDecisionManager An AccessDecisionManager instance
*/
- public function __construct(AccessDecisionManager $accessDecisionManager = null)
+ public function __construct(AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager = null, $alwaysAuthenticate = false)
{
+ $this->authenticationManager = $authenticationManager;
$this->accessDecisionManager = $accessDecisionManager;
+ $this->alwaysAuthenticate = $alwaysAuthenticate;
}
public function getUser()
@@ -60,6 +65,10 @@ class SecurityContext
$object = new FieldVote($object, $field);
}
+ if ($this->alwaysAuthenticate || !$this->token->isAuthenticated()) {
+ $this->token = $this->authenticationManager->authenticate($this->token);
+ }
+
return $this->accessDecisionManager->decide($this->token, (array) $attributes, $object);
}