mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
Implemented more methods
This commit is contained in:
parent
6cb5863b81
commit
29b09227ac
@ -73,7 +73,12 @@ class AccessTokenStorage extends Adapter implements AccessTokenInterface
|
|||||||
*/
|
*/
|
||||||
public function create($token, $expireTime, $sessionId)
|
public function create($token, $expireTime, $sessionId)
|
||||||
{
|
{
|
||||||
die(var_dump(__METHOD__, func_get_args()));
|
Capsule::table('oauth_access_tokens')
|
||||||
|
->insert([
|
||||||
|
'access_token' => $token,
|
||||||
|
'session_id' => $sessionId,
|
||||||
|
'expire_time' => $expireTime
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,13 +24,14 @@ class AuthCodeStorage extends Adapter implements AuthCodeInterface
|
|||||||
if (count($result) === 1) {
|
if (count($result) === 1) {
|
||||||
$token = new AuthCodeEntity($this->server);
|
$token = new AuthCodeEntity($this->server);
|
||||||
$token->setId($result[0]['auth_code']);
|
$token->setId($result[0]['auth_code']);
|
||||||
|
$token->setRedirectUri($result[0]['client_redirect_uri']);
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create($token, $$expireTime, $sessionId)
|
public function create($token, $expireTime, $sessionId, $redirectUri)
|
||||||
{
|
{
|
||||||
Capsule::table('oauth_auth_codes')
|
Capsule::table('oauth_auth_codes')
|
||||||
->insert([
|
->insert([
|
||||||
@ -46,7 +47,25 @@ class AuthCodeStorage extends Adapter implements AuthCodeInterface
|
|||||||
*/
|
*/
|
||||||
public function getScopes(AuthCodeEntity $token)
|
public function getScopes(AuthCodeEntity $token)
|
||||||
{
|
{
|
||||||
die(var_dump(__METHOD__, func_get_args()));
|
$result = Capsule::table('oauth_auth_code_scopes')
|
||||||
|
->select(['oauth_scopes.id', 'oauth_scopes.description'])
|
||||||
|
->join('oauth_scopes', 'oauth_auth_code_scopes.scope', '=', 'oauth_scopes.id')
|
||||||
|
->where('auth_code', $token->getId())
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$response = [];
|
||||||
|
|
||||||
|
if (count($result) > 0) {
|
||||||
|
foreach ($result as $row) {
|
||||||
|
$scope = (new ScopeEntity($this->server))->hydrate([
|
||||||
|
'id' => $row['id'],
|
||||||
|
'description' => $row['description']
|
||||||
|
]);
|
||||||
|
$response[] = $scope;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +75,7 @@ class AuthCodeStorage extends Adapter implements AuthCodeInterface
|
|||||||
{
|
{
|
||||||
Capsule::table('oauth_auth_code_scopes')
|
Capsule::table('oauth_auth_code_scopes')
|
||||||
->insert([
|
->insert([
|
||||||
'auth_code' => $token->getToken(),
|
'auth_code' => $token->getId(),
|
||||||
'scope' => $scope->getId()
|
'scope' => $scope->getId()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -66,6 +85,8 @@ class AuthCodeStorage extends Adapter implements AuthCodeInterface
|
|||||||
*/
|
*/
|
||||||
public function delete(AuthCodeEntity $token)
|
public function delete(AuthCodeEntity $token)
|
||||||
{
|
{
|
||||||
die(var_dump(__METHOD__, func_get_args()));
|
Capsule::table('oauth_auth_codes')
|
||||||
|
->where('auth_code', $token->getId())
|
||||||
|
->delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,10 @@ class SessionStorage extends Adapter implements SessionInterface
|
|||||||
$result = Capsule::table('oauth_sessions')
|
$result = Capsule::table('oauth_sessions')
|
||||||
->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri'])
|
->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri'])
|
||||||
->join('oauth_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id')
|
->join('oauth_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id')
|
||||||
->where('oauth_access_tokens.access_token', $accessToken->getToken())
|
->where('oauth_access_tokens.access_token', $accessToken->getId())
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if (count($result) === 1) {
|
if (count($result) === 1) {
|
||||||
// die(var_dump($result));
|
|
||||||
$session = new SessionEntity($this->server);
|
$session = new SessionEntity($this->server);
|
||||||
$session->setId($result[0]['id']);
|
$session->setId($result[0]['id']);
|
||||||
$session->setOwner($result[0]['owner_type'], $result[0]['owner_id']);
|
$session->setOwner($result[0]['owner_type'], $result[0]['owner_id']);
|
||||||
@ -49,7 +48,21 @@ class SessionStorage extends Adapter implements SessionInterface
|
|||||||
*/
|
*/
|
||||||
public function getByAuthCode(AuthCodeEntity $authCode)
|
public function getByAuthCode(AuthCodeEntity $authCode)
|
||||||
{
|
{
|
||||||
die(var_dump(__METHOD__, func_get_args()));
|
$result = Capsule::table('oauth_sessions')
|
||||||
|
->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri'])
|
||||||
|
->join('oauth_auth_codes', 'oauth_auth_codes.session_id', '=', 'oauth_sessions.id')
|
||||||
|
->where('oauth_auth_codes.auth_code', $authCode->getId())
|
||||||
|
->get();
|
||||||
|
|
||||||
|
if (count($result) === 1) {
|
||||||
|
$session = new SessionEntity($this->server);
|
||||||
|
$session->setId($result[0]['id']);
|
||||||
|
$session->setOwner($result[0]['owner_type'], $result[0]['owner_id']);
|
||||||
|
|
||||||
|
return $session;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,9 +80,10 @@ class SessionStorage extends Adapter implements SessionInterface
|
|||||||
$scopes = [];
|
$scopes = [];
|
||||||
|
|
||||||
foreach ($result as $scope) {
|
foreach ($result as $scope) {
|
||||||
$scopes[] = (new ScopeEntity($this->server))
|
$scopes[] = (new ScopeEntity($this->server))->hydrate([
|
||||||
->setId($scope['id'])
|
'id' => $scope['id'],
|
||||||
->setDescription($scope['description']);
|
'description' => $scope['description']
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $scopes;
|
return $scopes;
|
||||||
@ -95,6 +109,10 @@ class SessionStorage extends Adapter implements SessionInterface
|
|||||||
*/
|
*/
|
||||||
public function associateScope(SessionEntity $session, ScopeEntity $scope)
|
public function associateScope(SessionEntity $session, ScopeEntity $scope)
|
||||||
{
|
{
|
||||||
die(var_dump(__CLASS__.'::'.__METHOD__, func_get_args()));
|
Capsule::table('oauth_session_scopes')
|
||||||
|
->insert([
|
||||||
|
'session_id' => $session->getId(),
|
||||||
|
'scope' => $scope->getId()
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user