Completed
Push — master ( 2a258c...683c35 )
by Alexandre
02:27
created

AuthorizationServer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 40 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Alexandre
5
 * Date: 12/03/2018
6
 * Time: 21:26
7
 */
8
9
namespace OAuth2\Extensions\OpenID\Roles\AuthorizationServer;
10
11
12
use OAuth2\Endpoints\AuthorizationRequestBuilder;
13
use OAuth2\Extensions\OpenID\Config;
14
use OAuth2\Extensions\OpenID\Endpoints\AuthorizationEndpoint;
15
use OAuth2\Extensions\OpenID\AuthorizationGrantTypes\Flows\AuthorizationCodeFlow;
16
use OAuth2\Extensions\OpenID\AuthorizationGrantTypes\Flows\HybridFlow;
17
use OAuth2\Extensions\OpenID\AuthorizationGrantTypes\Flows\ImplicitFlow;
18
use OAuth2\Extensions\OpenID\IdTokenManager;
19
use OAuth2\Extensions\OpenID\Storages\StorageManager;
20
use OAuth2\Roles\AuthorizationServer\EndUserInterface;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, OAuth2\Extensions\OpenID...Server\EndUserInterface. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
21
use OAuth2\ScopePolicy\ScopePolicyManager;
22
23
class AuthorizationServer extends \OAuth2\Roles\AuthorizationServer\AuthorizationServer
24
{
25
    protected $idTokenManager;
26
27
    public function __construct(Config $config,
28
                                StorageManager $storageManager,
29
                                ScopePolicyManager $scopePolicyManager,
30
                                EndUserInterface $authorizationServerEndUser)
31
    {
32
        parent::__construct($config, $storageManager, $scopePolicyManager, $authorizationServerEndUser);
33
34
        $this->idTokenManager = new IdTokenManager($config);
35
36
        $this->flowManager->addFlow(new AuthorizationCodeFlow(
37
            $storageManager->getAuthorizationCodeStorage(),
38
            $storageManager->getAccessTokenStorage(),
39
            $storageManager->getRefreshTokenStorage(),
40
            $storageManager->getClientStorage(),
41
            $storageManager->getResourceOwnerStorage(),
42
            $this->idTokenManager
43
        ));
44
45
        $this->flowManager->addFlow(new ImplicitFlow(
46
            $storageManager->getAccessTokenStorage(),
47
            $storageManager->getRefreshTokenStorage(),
48
            $this->idTokenManager
49
        ));
50
51
        $this->flowManager->addFlow(new HybridFlow(
52
            $storageManager->getAuthorizationCodeStorage(),
53
            $storageManager->getAccessTokenStorage(),
54
            $storageManager->getRefreshTokenStorage(),
55
            $this->idTokenManager
56
        ));
57
58
        $authorizationRequestBuilder = new AuthorizationRequestBuilder(
59
            $storageManager->getClientStorage(),
60
            $this->responseTypeManager,
61
            $this->responseModeManager,
62
            $this->scopePolicyManager
63
        );
64
        $this->authorizationEndpoint = new AuthorizationEndpoint(
65
            $authorizationRequestBuilder,
66
            $authorizationServerEndUser
67
        );
68
    }
69
}