Go to the documentation of this file.
23 OpenIDAuthorizationCodeInterface
30 if ($connection instanceof \Couchbase) {
31 $this->db = $connection;
33 if (!is_array($connection) || !is_array($connection[
'servers'])) {
34 throw new \InvalidArgumentException(
'First argument to OAuth2\Storage\CouchbaseDB must be an instance of Couchbase or a configuration array containing a server array');
37 $this->db = new \Couchbase($connection[
'servers'], (!isset($connection[
'username'])) ?
'' : $connection[
'username'], (!isset($connection[
'password'])) ?
'' : $connection[
'password'], $connection[
'bucket'],
false);
40 $this->config = array_merge(array(
41 'client_table' =>
'oauth_clients',
42 'access_token_table' =>
'oauth_access_tokens',
43 'refresh_token_table' =>
'oauth_refresh_tokens',
44 'code_table' =>
'oauth_authorization_codes',
45 'user_table' =>
'oauth_users',
46 'jwt_table' =>
'oauth_jwt',
53 return json_decode($this->db->get($this->config[$name].
'-'.$id),
true);
59 $array[
'type'] = $name;
61 return $this->db->set($this->config[$name].
'-'.$id,json_encode($array));
67 $this->db->delete($this->config[$name].
'-'.$id,
"",1);
74 return $result[
'client_secret'] == $client_secret;
86 return empty($result[
'client_secret']);
94 return is_null($result) ?
false : $result;
97 public function setClientDetails($client_id, $client_secret =
null, $redirect_uri =
null, $grant_types =
null, $scope =
null, $user_id =
null)
102 'client_id' => $client_id,
103 'client_secret' => $client_secret,
104 'redirect_uri' => $redirect_uri,
105 'grant_types' => $grant_types,
107 'user_id' => $user_id,
111 'client_id' => $client_id,
112 'client_secret' => $client_secret,
113 'redirect_uri' => $redirect_uri,
114 'grant_types' => $grant_types,
116 'user_id' => $user_id,
126 if (isset($details[
'grant_types'])) {
127 $grant_types = explode(
' ', $details[
'grant_types']);
129 return in_array($grant_type, $grant_types);
141 return is_null($token) ?
false : $token;
144 public function setAccessToken($access_token, $client_id, $user_id, $expires, $scope =
null)
149 'access_token' => $access_token,
150 'client_id' => $client_id,
151 'expires' => $expires,
152 'user_id' => $user_id,
157 'access_token' => $access_token,
158 'client_id' => $client_id,
159 'expires' => $expires,
160 'user_id' => $user_id,
173 return is_null($code) ?
false : $code;
176 public function setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope =
null, $id_token =
null)
181 'authorization_code' => $code,
182 'client_id' => $client_id,
183 'user_id' => $user_id,
184 'redirect_uri' => $redirect_uri,
185 'expires' => $expires,
187 'id_token' => $id_token,
191 'authorization_code' => $code,
192 'client_id' => $client_id,
193 'user_id' => $user_id,
194 'redirect_uri' => $redirect_uri,
195 'expires' => $expires,
197 'id_token' => $id_token,
214 if ($user = $this->
getUser($username)) {
223 if ($user = $this->
getUser($username)) {
224 $user[
'user_id'] = $user[
'username'];
235 return is_null($token) ?
false : $token;
238 public function setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope =
null)
241 'refresh_token' => $refresh_token,
242 'client_id' => $client_id,
243 'user_id' => $user_id,
244 'expires' => $expires,
261 return $user[
'password'] == $password;
268 return is_null($result) ?
false : $result;
271 public function setUser($username, $password, $firstName =
null, $lastName =
null)
273 if ($this->
getUser($username)) {
275 'username' => $username,
276 'password' => $password,
277 'first_name' => $firstName,
278 'last_name' => $lastName
283 'username' => $username,
284 'password' => $password,
285 'first_name' => $firstName,
286 'last_name' => $lastName
300 if (isset($jwt[
'subject']) && $jwt[
'subject'] == $subject) {
313 if (isset($clientDetails[
'scope'])) {
314 return $clientDetails[
'scope'];
320 public function getJti($client_id, $subject, $audience, $expiration, $jti)
323 throw new \Exception(
'getJti() for the Couchbase driver is currently unimplemented.');
326 public function setJti($client_id, $subject, $audience, $expiration, $jti)
329 throw new \Exception(
'setJti() for the Couchbase driver is currently unimplemented.');
checkRestrictedGrantType($client_id, $grant_type)
getAuthorizationCode($code)
getUserDetails($username)
setRefreshToken($refresh_token, $client_id, $user_id, $expires, $scope=null)
getRefreshToken($refresh_token)
checkPassword($user, $password)
GNU LESSER GENERAL PUBLIC LICENSE February Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license but changing it is not allowed[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it By the GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This the Lesser General Public applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular based on the explanations below When we speak of free we are referring to freedom of use
setAuthorizationCode($code, $client_id, $user_id, $redirect_uri, $expires, $scope=null, $id_token=null)
getClientKey($client_id, $subject)
getClientScope($client_id)
getClientDetails($client_id)
setJti($client_id, $subject, $audience, $expiration, $jti)
setClientDetails($client_id, $client_secret=null, $redirect_uri=null, $grant_types=null, $scope=null, $user_id=null)
unsetRefreshToken($refresh_token)
setUser($username, $password, $firstName=null, $lastName=null)
checkUserCredentials($username, $password)
__construct($connection, $config=array())
isPublicClient($client_id)
expireAuthorizationCode($code)
setObjectByType($name, $id, $array)
getObjectByType($name, $id)
deleteObjectByType($name, $id)
getAccessToken($access_token)
Attr AllowedRel this is empty
getJti($client_id, $subject, $audience, $expiration, $jti)
setAccessToken($access_token, $client_id, $user_id, $expires, $scope=null)
checkClientCredentials($client_id, $client_secret=null)
if(!defined("FALSE_VAL")) define("FALSE_VAL" false