|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Security\Http\Authentication; |
|
15
|
|
|
|
|
16
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
17
|
|
|
use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; |
|
18
|
|
|
use Symfony\Component\Security\Http\ParameterBagUtils; |
|
19
|
|
|
use Symfony\Component\Security\Http\Util\TargetPathTrait; |
|
20
|
|
|
|
|
21
|
|
|
class EccubeAuthenticationSuccessHandler extends DefaultAuthenticationSuccessHandler |
|
22
|
|
|
{ |
|
23
|
|
|
use TargetPathTrait; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Builds the target URL according to the defined options. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function determineTargetUrl(Request $request) |
|
31
|
|
|
{ |
|
32
|
|
|
if ($this->options['always_use_default_target_path']) { |
|
33
|
|
|
return $this->options['default_target_path']; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
if ($targetUrl = ParameterBagUtils::getRequestParameterValue($request, $this->options['target_path_parameter'])) { |
|
37
|
|
|
if (preg_match('/^https?:\\\\/i', $targetUrl)) { |
|
38
|
|
|
$targetUrl = '/'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return $targetUrl; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
if (null !== $this->providerKey && $targetUrl = $this->getTargetPath($request->getSession(), $this->providerKey)) { |
|
|
|
|
|
|
45
|
|
|
$this->removeTargetPath($request->getSession(), $this->providerKey); |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
return $targetUrl; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
if ($this->options['use_referer'] && $targetUrl = $request->headers->get('Referer')) { |
|
51
|
|
|
if (false !== $pos = strpos($targetUrl, '?')) { |
|
52
|
|
|
$targetUrl = substr($targetUrl, 0, $pos); |
|
53
|
|
|
} |
|
54
|
|
|
if ($targetUrl && $targetUrl !== $this->httpUtils->generateUri($request, $this->options['login_path'])) { |
|
55
|
|
|
return $targetUrl; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $this->options['default_target_path']; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: