Implementing storage interfaces

This commit is contained in:
Josh Sherman 2014-10-14 07:11:03 -04:00
parent 49a713eb35
commit c244e02d46
2 changed files with 31 additions and 12 deletions

View file

@ -55,25 +55,27 @@ class ClientStorage extends StorageAdapter implements ClientInterface
public function getBySession(SessionEntity $session)
{
/*
$result = Capsule::table('oauth_clients')
->select(['oauth_clients.id', 'oauth_clients.name'])
->join('oauth_sessions', 'oauth_clients.id', '=', 'oauth_sessions.client_id')
->where('oauth_sessions.id', $session->getId())
->get();
$sql = 'SELECT oauth_clients.id, oauth_clients.name'
. ' FROM oauth_clients'
. ' JOIN oauth_sessions'
. ' ON oauth_clients.id = oauth_sessions.client_id'
. ' WHERE oauth_sessions.id = ?';
if (count($result) === 1) {
$results = $this->db->fetch($sql, [$session->getId()]);
if (count($results) === 1)
{
$client = new ClientEntity($this->server);
$client->hydrate([
'id' => $result[0]['id'],
'name' => $result[0]['name']
'id' => $results[0]['id'],
'name' => $results[0]['name']
]);
return $client;
}
return null;
*/
}
}

View file

@ -14,6 +14,12 @@
namespace Pickles;
use \League\OAuth2\Server\ResourceServer;
use Pickles\OAuth2\AccessTokenStorage;
use Pickles\OAuth2\ClientStorage;
use Pickles\OAuth2\ScopeStorage;
use Pickles\OAuth2\SessionStorage;
/**
* Resource Class
*
@ -74,11 +80,22 @@ class Resource extends Object
try
{
// Check auth if flag is explicitly true or is true for the method
// Checks if auth flag is explicity true or true for the method
if ($this->auth === true
|| (isset($this->auth[$method]) && $this->auth[$method]))
{
if (!isset($this->config['oauth2'][$_SERVER['__version']]))
if (isset($this->config['oauth'][$_SERVER['__version']]))
{
$server = new ResourceServer(
new SessionStorage,
new AccessTokenStorage,
new ClientStorage,
new ScopeStorage
);
$server->isValidRequest();
}
else
{
throw new \Exception('Authentication is not configured properly.', 401);
}