|
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; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use Firebase\JWT\JWT; |
|
13
|
|
|
use OAuth2\Config; |
|
14
|
|
|
use OAuth2\Extensions\OpenID\Endpoints\AuthorizationEndpoint; |
|
15
|
|
|
use OAuth2\Extensions\OpenID\Flows\AuthorizationCodeFlow; |
|
16
|
|
|
use OAuth2\Extensions\OpenID\Flows\ImplicitFlow; |
|
17
|
|
|
use OAuth2\Extensions\OpenID\Roles\ResourceOwnerInterface; |
|
18
|
|
|
use OAuth2\Storages\StorageManager; |
|
19
|
|
|
|
|
20
|
|
|
class Server extends \OAuth2\Server |
|
21
|
|
|
{ |
|
22
|
|
|
protected $idTokenManager; |
|
23
|
|
|
|
|
24
|
|
|
public function __construct(Config $config, StorageManager $storageManager, ResourceOwnerInterface $resourceOwner) |
|
25
|
|
|
{ |
|
26
|
|
|
parent::__construct($config, $storageManager, $resourceOwner); |
|
27
|
|
|
|
|
28
|
|
|
$this->idTokenManager = new IdTokenManager(new JWT()); |
|
29
|
|
|
|
|
30
|
|
|
$this->flowManager->addFlow(new AuthorizationCodeFlow( |
|
31
|
|
|
$storageManager->getAuthorizationCodeStorage(), |
|
32
|
|
|
$storageManager->getAccessTokenStorage(), |
|
33
|
|
|
$storageManager->getRefreshTokenStorage() |
|
34
|
|
|
)); |
|
35
|
|
|
|
|
36
|
|
|
$this->flowManager->addFlow(new ImplicitFlow( |
|
37
|
|
|
$this->idTokenManager, |
|
38
|
|
|
$storageManager->getAccessTokenStorage(), |
|
39
|
|
|
$storageManager->getRefreshTokenStorage() |
|
40
|
|
|
)); |
|
41
|
|
|
|
|
42
|
|
|
$this->authorizationEndpoint = new AuthorizationEndpoint( |
|
43
|
|
|
$this->responseTypeManager, |
|
44
|
|
|
$this->responseModeManager, |
|
45
|
|
|
$this->scopePolicyManager, |
|
46
|
|
|
$resourceOwner, |
|
47
|
|
|
$storageManager->getClientStorage(), |
|
48
|
|
|
$this->idTokenManager |
|
49
|
|
|
); |
|
50
|
|
|
} |
|
51
|
|
|
} |