diff options
| author | Brent Shaffer <bshafs@gmail.com> | 2014-02-27 08:51:21 +0400 |
|---|---|---|
| committer | Brent Shaffer <bshafs@gmail.com> | 2014-02-27 08:51:21 +0400 |
| commit | bd41360a803016ad0f59cd291a65bc0e2a274c64 (patch) | |
| tree | 1b87b55429ac535c720cc245bb0948157025bc44 /src | |
| parent | 4929e32b8ec25397337c00ecd28c76fe31d27171 (diff) | |
| download | oauth2-server-php-bd41360a803016ad0f59cd291a65bc0e2a274c64.tar.xz | |
adds tests for JwtBearer storage
Diffstat (limited to 'src')
| -rw-r--r-- | src/OAuth2/Storage/Cassandra.php | 14 | ||||
| -rw-r--r-- | src/OAuth2/Storage/Mongo.php | 2 | ||||
| -rw-r--r-- | src/OAuth2/Storage/Redis.php | 15 |
3 files changed, 27 insertions, 4 deletions
diff --git a/src/OAuth2/Storage/Cassandra.php b/src/OAuth2/Storage/Cassandra.php index 4f97ef2..b63a752 100644 --- a/src/OAuth2/Storage/Cassandra.php +++ b/src/OAuth2/Storage/Cassandra.php @@ -316,7 +316,10 @@ class Cassandra implements AuthorizationCodeInterface, /*JWTBearerInterface */ public function getClientKey($client_id, $subject) { - $jwt = $this->getValue($this->config['jwt_key'] . $client_id); + if (!$jwt = $this->getValue($this->config['jwt_key'] . $client_id)) { + return false; + } + if (isset($jwt['subject']) && $jwt['subject'] == $subject ) { return $jwt['key']; } @@ -324,6 +327,15 @@ class Cassandra implements AuthorizationCodeInterface, return null; } + public function setClientKey($client_id, $key, $subject = null) + { + return $this->setValue($this->config['jwt_key'] . $client_id, array( + 'key' => $key, + 'subject' => $subject + )); + } + + /*ScopeInterface */ public function getClientScope($client_id) { if (!$clientDetails = $this->getClientDetails($client_id)) { diff --git a/src/OAuth2/Storage/Mongo.php b/src/OAuth2/Storage/Mongo.php index ebb34f1..60db771 100644 --- a/src/OAuth2/Storage/Mongo.php +++ b/src/OAuth2/Storage/Mongo.php @@ -304,7 +304,7 @@ class Mongo implements AuthorizationCodeInterface, 'subject' => $subject )); - return $result; + return is_null($result) ? false : $result['key']; } public function getClientScope($client_id) diff --git a/src/OAuth2/Storage/Redis.php b/src/OAuth2/Storage/Redis.php index ff3fe16..28c36df 100644 --- a/src/OAuth2/Storage/Redis.php +++ b/src/OAuth2/Storage/Redis.php @@ -263,14 +263,25 @@ class Redis implements AuthorizationCodeInterface, /*JWTBearerInterface */ public function getClientKey($client_id, $subject) { - $jwt = $this->getValue($this->config['jwt_key'] . $client_id); - if ( isset($jwt['subject']) && $jwt['subject'] == $subject ) { + if (!$jwt = $this->getValue($this->config['jwt_key'] . $client_id)) { + return false; + } + + if (isset($jwt['subject']) && $jwt['subject'] == $subject) { return $jwt['key']; } return null; } + public function setClientKey($client_id, $key, $subject = null) + { + return $this->setValue($this->config['jwt_key'] . $client_id, array( + 'key' => $key, + 'subject' => $subject + )); + } + public function getClientScope($client_id) { if (!$clientDetails = $this->getClientDetails($client_id)) { |
