|
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; |
|
|
|
|
|
|
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
|
|
|
} |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/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: