1 | <?php namespace nyx\auth\id\protocols\oauth2; |
||
19 | class Token extends auth\Token |
||
20 | { |
||
21 | /** |
||
22 | * The traits of a OAuth 2.0 Access Token instance. |
||
23 | */ |
||
24 | use core\traits\Serializable; |
||
25 | |||
26 | /** |
||
27 | * @var auth\Token The refresh Token for this Access Token. |
||
28 | */ |
||
29 | protected $refreshToken; |
||
30 | |||
31 | /** |
||
32 | * @var int The expiry time of this Token in seconds. |
||
33 | */ |
||
34 | protected $expiry; |
||
35 | |||
36 | /** |
||
37 | * @var array The scopes this Token is known to grant access to, if applicable. |
||
38 | * Note: For faster lookups the actual scopes are stored as keys of this array. |
||
39 | */ |
||
40 | protected $scopes = []; |
||
41 | |||
42 | /** |
||
43 | * {@inheritDoc} |
||
44 | */ |
||
45 | public function matches(auth\interfaces\Token $that) : bool |
||
67 | |||
68 | /** |
||
69 | * Determines whether this Token is known to grant access to a specific scope. |
||
70 | * |
||
71 | * @param string $scope The name of the scope to check for. |
||
72 | * @return bool |
||
73 | */ |
||
74 | public function authorizes(string $scope) : bool |
||
78 | |||
79 | /** |
||
80 | * Returns the scopes this Token is known to grant access to. |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | public function getScopes() : array |
||
88 | |||
89 | /** |
||
90 | * Sets the scopes this Token is known to grant access to. |
||
91 | * |
||
92 | * @param array $scopes The scopes to set. |
||
93 | * @return $this |
||
94 | */ |
||
95 | public function setScopes(array $scopes) : oauth2\Token |
||
105 | |||
106 | /** |
||
107 | * Returns the refresh Token for this Access Token. |
||
108 | * |
||
109 | * @return auth\Token |
||
110 | */ |
||
111 | public function getRefreshToken() : ?auth\Token |
||
115 | |||
116 | /** |
||
117 | * Sets the refresh Token for this Access Token. |
||
118 | * |
||
119 | * @param auth\Token|string $token |
||
120 | * @return $this |
||
121 | */ |
||
122 | public function setRefreshToken($token) : oauth2\Token |
||
135 | |||
136 | /** |
||
137 | * Returns the expiry time of this Token in seconds. |
||
138 | * |
||
139 | * @return int |
||
140 | */ |
||
141 | public function getExpiry() : ?int |
||
145 | |||
146 | /** |
||
147 | * Sets the expiry time of this Token in seconds. |
||
148 | * |
||
149 | * @param int $time The expiry time in seconds. |
||
150 | * @return $this |
||
151 | */ |
||
152 | public function setExpiry(int $time) : oauth2\Token |
||
158 | |||
159 | /** |
||
160 | * {@inheritDoc} |
||
161 | */ |
||
162 | public function unserialize($data) |
||
172 | |||
173 | /** |
||
174 | * {@inheritDoc} |
||
175 | */ |
||
176 | public function toString() : string |
||
180 | |||
181 | /** |
||
182 | * {@inheritDoc} |
||
183 | */ |
||
184 | public function toArray() : array |
||
193 | } |
||
194 |