1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CodeCloud\Bundle\ShopifyBundle\Security; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\HttpFoundation\RedirectResponse; |
6
|
|
|
use Symfony\Component\HttpFoundation\Request; |
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
8
|
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; |
9
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
|
|
|
|
10
|
|
|
use Symfony\Component\Security\Core\Exception\AuthenticationException; |
|
|
|
|
11
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
|
|
|
12
|
|
|
use Symfony\Component\Security\Core\User\UserProviderInterface; |
|
|
|
|
13
|
|
|
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; |
|
|
|
|
14
|
|
|
|
15
|
|
|
class SessionAuthenticator extends AbstractGuardAuthenticator |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var UrlGeneratorInterface |
19
|
|
|
*/ |
20
|
|
|
private $urlGenerator; |
21
|
|
|
|
22
|
|
|
public function __construct(UrlGeneratorInterface $urlGenerator) |
23
|
|
|
{ |
24
|
|
|
$this->urlGenerator = $urlGenerator; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function supports(Request $request) |
28
|
|
|
{ |
29
|
|
|
return (bool) $this->getSessionId($request); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
private function getSessionId(Request $request) |
33
|
|
|
{ |
34
|
|
|
return $request->query->get('shopify_session_id', $request->get('shopify_session_id')); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function getCredentials(Request $request) |
38
|
|
|
{ |
39
|
|
|
return [ |
40
|
|
|
'shopify_session_id' => $this->getSessionId($request), |
41
|
|
|
]; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getUser($credentials, UserProviderInterface $userProvider) |
45
|
|
|
{ |
46
|
|
|
return $userProvider->loadUserByUsername($credentials['shopify_session_id']); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function checkCredentials($credentials, UserInterface $user) |
50
|
|
|
{ |
51
|
|
|
return true; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function onAuthenticationFailure(Request $request, AuthenticationException $exception) |
55
|
|
|
{ |
56
|
|
|
return null; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey) |
60
|
|
|
{ |
61
|
|
|
return null; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function supportsRememberMe() |
65
|
|
|
{ |
66
|
|
|
return false; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function start(Request $request, AuthenticationException $authException = null) |
70
|
|
|
{ |
71
|
|
|
if (!$request->get('shop')) { |
72
|
|
|
return new Response('Your session has expired. Please access the app via Shopify Admin again.'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return new RedirectResponse( |
76
|
|
|
$this->urlGenerator->generate('codecloud_shopify_auth', [ |
77
|
|
|
'shop' => $request->get('shop'), |
78
|
|
|
]) |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths