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 $tokenGenerator; |
16
|
|
|
private $options = [ |
17
|
|
|
'always_require_a_client' => false, |
18
|
|
|
'access_token_ttl' => 3600, |
19
|
|
|
'refresh_token_ttl' => 3600, |
20
|
|
|
'access_token_length' => 32, |
21
|
|
|
'revoke_refresh_token_when_used' => true, |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
public function __construct(TokenGenerator $tokenGenerator, array $options = []) |
25
|
|
|
{ |
26
|
|
|
$this->tokenGenerator = $tokenGenerator; |
27
|
|
|
$this->options = array_merge($this->options, $options); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function alwaysRequireAClient() |
31
|
|
|
{ |
32
|
|
|
return $this->options['always_require_a_client']; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function alwaysGenerateARefreshToken() |
36
|
|
|
{ |
37
|
|
|
return $this->options['always_generate_a_refresh_token']; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function shouldRevokeRefreshTokenWhenUsed() |
41
|
|
|
{ |
42
|
|
|
return $this->options['revoke_refresh_token_when_used']; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getAccessTokenTTL() |
46
|
|
|
{ |
47
|
|
|
return $this->options['access_token_ttl']; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function getRefreshTokenTTL() |
51
|
|
|
{ |
52
|
|
|
return $this->options['refresh_token_ttl']; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getTokenGenerator() |
56
|
|
|
{ |
57
|
|
|
return $this->tokenGenerator; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function getAccessTokenLength() |
61
|
|
|
{ |
62
|
|
|
return $this->options['access_token_length']; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|