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; |
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\AuthorizationServerEndUserInterface; |
21
|
|
|
|
22
|
|
|
class AuthorizationServer extends \OAuth2\Roles\AuthorizationServer |
23
|
|
|
{ |
24
|
|
|
protected $idTokenManager; |
25
|
|
|
|
26
|
|
|
public function __construct(Config $config, StorageManager $storageManager, |
27
|
|
|
AuthorizationServerEndUserInterface $authorizationServerEndUser) |
28
|
|
|
{ |
29
|
|
|
parent::__construct($config, $storageManager, $authorizationServerEndUser); |
30
|
|
|
|
31
|
|
|
$this->idTokenManager = new IdTokenManager($config); |
32
|
|
|
|
33
|
|
|
$this->flowManager->addFlow(new AuthorizationCodeFlow( |
34
|
|
|
$storageManager->getAuthorizationCodeStorage(), |
35
|
|
|
$storageManager->getAccessTokenStorage(), |
36
|
|
|
$storageManager->getRefreshTokenStorage(), |
37
|
|
|
$storageManager->getClientStorage(), |
38
|
|
|
$storageManager->getResourceOwnerStorage(), |
39
|
|
|
$this->idTokenManager |
40
|
|
|
)); |
41
|
|
|
|
42
|
|
|
$this->flowManager->addFlow(new ImplicitFlow( |
43
|
|
|
$storageManager->getAccessTokenStorage(), |
44
|
|
|
$storageManager->getRefreshTokenStorage(), |
45
|
|
|
$this->idTokenManager |
46
|
|
|
)); |
47
|
|
|
|
48
|
|
|
$this->flowManager->addFlow(new HybridFlow( |
49
|
|
|
$storageManager->getAuthorizationCodeStorage(), |
50
|
|
|
$storageManager->getAccessTokenStorage(), |
51
|
|
|
$storageManager->getRefreshTokenStorage(), |
52
|
|
|
$this->idTokenManager |
53
|
|
|
)); |
54
|
|
|
|
55
|
|
|
$authorizationRequestBuilder = new AuthorizationRequestBuilder( |
56
|
|
|
$storageManager->getClientStorage(), |
57
|
|
|
$this->responseTypeManager, |
58
|
|
|
$this->responseModeManager, |
59
|
|
|
$this->scopePolicyManager |
60
|
|
|
); |
61
|
|
|
$this->authorizationEndpoint = new AuthorizationEndpoint( |
62
|
|
|
$authorizationRequestBuilder, |
63
|
|
|
$authorizationServerEndUser |
64
|
|
|
); |
65
|
|
|
} |
66
|
|
|
} |