Adicion de END POINTS para tokens (EXPIRE y DELETE)
This commit is contained in:
@@ -145,6 +145,24 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
|
|||||||
return $stmt->execute(compact('code'));
|
return $stmt->execute(compact('code'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function expireToken($token)
|
||||||
|
{
|
||||||
|
$access_token = new \OauthAccessTokens();
|
||||||
|
$access_token->load($token);
|
||||||
|
$stmt = $this->db->prepare(sprintf('UPDATE %s SET EXPIRES=%s WHERE ACCESS_TOKEN=:token', $this->config['access_token_table'], "'".Date('Y-m-d H:i:s')."'"));
|
||||||
|
return $stmt->execute(compact('token'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteToken($token)
|
||||||
|
{
|
||||||
|
$access_token = new \OauthAccessTokens();
|
||||||
|
$access_token->load($token);
|
||||||
|
$stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE ACCESS_TOKEN = :token', $this->config['access_token_table']));
|
||||||
|
$stmt->execute(compact('token'));
|
||||||
|
$stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE EXPIRES>%s', $this->config['refresh_token_table'], "'".Date('Y-m-d H:i:s')."'"));
|
||||||
|
return $stmt->execute(compact('token'));
|
||||||
|
}
|
||||||
|
|
||||||
/* OAuth2_Storage_UserCredentialsInterface */
|
/* OAuth2_Storage_UserCredentialsInterface */
|
||||||
public function checkUserCredentials($username, $password)
|
public function checkUserCredentials($username, $password)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,6 +73,32 @@ class Server implements iAuthenticate
|
|||||||
$this->server->setScopeUtil($scope);
|
$this->server->setScopeUtil($scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url POST /:token/expire
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function doPostExpireToken($token)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->storage->expireToken($token);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RestException(400, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url DELETE /:token
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function doDeleteToken($token)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->storage->deleteToken($token);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw new RestException(400, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function setDatabaseSource($user, $password = '', $dsn = '')
|
public static function setDatabaseSource($user, $password = '', $dsn = '')
|
||||||
{
|
{
|
||||||
if (is_array($user)) {
|
if (is_array($user)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user