diff options
Diffstat (limited to 'Http/Session/SessionAuthenticationStrategy.php')
-rw-r--r-- | Http/Session/SessionAuthenticationStrategy.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Http/Session/SessionAuthenticationStrategy.php b/Http/Session/SessionAuthenticationStrategy.php new file mode 100644 index 0000000..64f787f --- /dev/null +++ b/Http/Session/SessionAuthenticationStrategy.php @@ -0,0 +1,39 @@ +<?php + +namespace Symfony\Component\Security\Http\Session; + +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\HttpFoundation\Request; + +class SessionAuthenticationStrategy implements SessionAuthenticationStrategyInterface +{ + const NONE = 'none'; + const MIGRATE = 'migrate'; + const INVALIDATE = 'invalidate'; + + protected $strategy; + + public function __construct($strategy) + { + $this->strategy = $strategy; + } + + public function onAuthentication(Request $request, TokenInterface $token) + { + switch ($this->strategy) { + case self::NONE: + return; + + case self::MIGRATE: + $request->getSession()->migrate(); + return; + + case self::INVALIDATE: + $request->getSession()->invalidate(); + return; + + default: + throw new \RuntimeException(sprintf('Invalid session authentication strategy "%s"', $this->strategy)); + } + } +}
\ No newline at end of file |