Passed
Pull Request — master (#9)
by Daniel
02:21
created

DevEntryPoint::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 5
rs 10
c 1
b 0
f 0
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\Security\Core\Authentication\Token\TokenInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...on\Token\TokenInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Symfony\Component\Security\Core\Exception\AuthenticationException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...AuthenticationException was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Security\Core\User\UserInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Security\Core\User\UserInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Symfony\Component\Security\Core\User\UserProviderInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...r\UserProviderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Symfony\Component\Security\Guard\AbstractGuardAuthenticator;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...tractGuardAuthenticator was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\Security\Guard\GuardAuthenticatorHandler;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...ardAuthenticatorHandler was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...PostAuthenticationToken was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Securi...tionEntryPointInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class DevEntryPoint implements AuthenticationEntryPointInterface
18
{
19
    /**
20
     * @var GuardAuthenticatorHandler
21
     */
22
    private $authHandler;
23
24
    /**
25
     * @var string
26
     */
27
    private $storeName;
28
29
    /**
30
     * @var string
31
     */
32
    private $firewallName;
33
34
    public function __construct(GuardAuthenticatorHandler $authHandler, $storeName, $firewallName)
35
    {
36
        $this->authHandler = $authHandler;
37
        $this->storeName = $storeName;
38
        $this->firewallName = $firewallName;
39
    }
40
41
    public function start(Request $request, AuthenticationException $authException = null)
42
    {
43
        $user = new ShopifyAdminUser($this->storeName, ["ROLE_SHOPIFY_ADMIN"]);
44
45
        $token = new PostAuthenticationToken(
46
            $user,
47
            $this->firewallName,
48
            $user->getRoles()
49
        );
50
51
        $this->authHandler->authenticateWithToken($token, $request, $this->firewallName);
52
53
        return new RedirectResponse($request->getUri());
54
    }
55
}
56