From 4d339e1eb4b6009758344103186a5e645815b37b Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Wed, 23 Mar 2016 19:37:57 -0300 Subject: [PATCH] Fix on revoke UI (Admin) client id was saved wrong, so there were sometimes that user cant revoke a token manually Change-Id: I8dafa8ebff832482af04ea17b6f5a2bb8db4742c --- app/controllers/apis/ClientApiController.php | 6 ++++-- app/services/oauth2/TokenService.php | 18 +++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/controllers/apis/ClientApiController.php b/app/controllers/apis/ClientApiController.php index b2b537c4..37337629 100644 --- a/app/controllers/apis/ClientApiController.php +++ b/app/controllers/apis/ClientApiController.php @@ -432,7 +432,8 @@ final class ClientApiController extends AbstractRESTController implements ICRUDC if (is_null($token)) { return $this->error404(array('error' => sprintf('access token %s does not exists!', $value))); } - if (intval($token->getClientId()) !== intval($client->id)) { + Log::debug(sprintf('access token client id %s - client id %s ',$token->getClientId() , $client->client_id)); + if ($token->getClientId() !== $client->client_id) { return $this->error412(array( 'error' => sprintf('access token %s does not belongs to client id !', $value, $id) )); @@ -445,7 +446,8 @@ final class ClientApiController extends AbstractRESTController implements ICRUDC if (is_null($token)) { return $this->error404(array('error' => sprintf('refresh token %s does not exists!', $value))); } - if (intval($token->getClientId()) !== intval($client->id)) { + Log::debug(sprintf('refresh token client id %s - client id %s ',$token->getClientId() , $client->client_id)); + if ($token->getClientId() !== $client->client_id) { return $this->error412(array( 'error' => sprintf('refresh token %s does not belongs to client id !', $value, $id) )); diff --git a/app/services/oauth2/TokenService.php b/app/services/oauth2/TokenService.php index 99aaf2ef..d18435a9 100644 --- a/app/services/oauth2/TokenService.php +++ b/app/services/oauth2/TokenService.php @@ -586,7 +586,6 @@ final class TokenService implements ITokenService return $access_token; } - /** * @param RefreshToken $refresh_token * @param null $scope @@ -760,16 +759,17 @@ final class TokenService implements ITokenService } $user_id = !is_null($access_token->user_id) ? $access_token->user_id : 0; + $client = $access_token->client()->first(); $this->cache_service->storeHash($access_token->value, array( - 'user_id' => $user_id, - 'client_id' => $access_token->client_id, - 'scope' => $access_token->scope, - 'auth_code' => $access_token->associated_authorization_code, - 'issued' => $access_token->created_at, - 'lifetime' => $access_token->lifetime, - 'from_ip' => $access_token->from_ip, - 'audience' => $access_token->audience, + 'user_id' => $user_id, + 'client_id' => $client->client_id, + 'scope' => $access_token->scope, + 'auth_code' => $access_token->associated_authorization_code, + 'issued' => $access_token->created_at, + 'lifetime' => $access_token->lifetime, + 'from_ip' => $access_token->from_ip, + 'audience' => $access_token->audience, 'refresh_token' => $refresh_token_value ) , intval($access_token->lifetime));