1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Boris Guéry <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Bgy\OAuth2; |
7
|
|
|
|
8
|
|
|
use Bgy\OAuth2\GrantType\GrantType; |
9
|
|
|
use Bgy\OAuth2\Storage\ClientStorage; |
10
|
|
|
use Bgy\OAuth2\Storage\AccessTokenStorage; |
11
|
|
|
use Bgy\OAuth2\Storage\RefreshTokenStorage; |
12
|
|
|
|
13
|
|
|
class AuthorizationServerConfiguration |
14
|
|
|
{ |
15
|
|
|
private $clientStorage; |
16
|
|
|
private $accessTokenStorage; |
17
|
|
|
private $refreshTokenStorage; |
18
|
|
|
private $tokenGenerator; |
19
|
|
|
private $options = [ |
20
|
|
|
'always_require_a_client' => false, |
21
|
|
|
'access_token_ttl' => 3600, |
22
|
|
|
'refresh_token_ttl' => 3600, |
23
|
|
|
'access_token_length' => 32, |
24
|
|
|
]; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var GrantType[] |
28
|
|
|
*/ |
29
|
|
|
private $grantTypes = []; |
30
|
|
|
|
31
|
|
|
public function __construct(ClientStorage $clientStorage, AccessTokenStorage $accessTokenStorage, |
32
|
|
|
RefreshTokenStorage $refreshTokenStorage, array $grantTypes, |
33
|
|
|
TokenGenerator $tokenGenerator, |
34
|
|
|
array $options = []) |
35
|
|
|
{ |
36
|
|
|
$this->clientStorage = $clientStorage; |
37
|
|
|
$this->accessTokenStorage = $accessTokenStorage; |
38
|
|
|
$this->refreshTokenStorage = $refreshTokenStorage; |
39
|
|
|
$this->grantTypes = $grantTypes; |
40
|
|
|
$this->tokenGenerator = $tokenGenerator; |
41
|
|
|
$this->options = array_merge($this->options, $options); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getClientStorage() |
45
|
|
|
{ |
46
|
|
|
return $this->clientStorage; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getAccessTokenStorage() |
50
|
|
|
{ |
51
|
|
|
return $this->accessTokenStorage; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getRefreshTokenStorage() |
55
|
|
|
{ |
56
|
|
|
return $this->refreshTokenStorage; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getGrantTypeExtensions() |
60
|
|
|
{ |
61
|
|
|
return $this->grantTypes; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function alwaysRequireAClient() |
65
|
|
|
{ |
66
|
|
|
return $this->options['always_require_a_client']; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function alwaysGenerateARefreshToken() |
70
|
|
|
{ |
71
|
|
|
return $this->options['always_generate_a_refresh_token']; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function getAccessTokenTTL() |
75
|
|
|
{ |
76
|
|
|
return $this->options['access_token_ttl']; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function getRefreshTokenTTL() |
80
|
|
|
{ |
81
|
|
|
return $this->options['refresh_token_ttl']; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public function getTokenGenerator() |
85
|
|
|
{ |
86
|
|
|
return $this->tokenGenerator; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function getAccessTokenLength() |
90
|
|
|
{ |
91
|
|
|
return $this->options['access_token_length']; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|