diff options
Diffstat (limited to 'apps/oauth2/lib')
-rw-r--r-- | apps/oauth2/lib/Controller/OauthApiController.php | 6 | ||||
-rw-r--r-- | apps/oauth2/lib/Db/AccessToken.php | 8 | ||||
-rw-r--r-- | apps/oauth2/lib/Db/AccessTokenMapper.php | 2 | ||||
-rw-r--r-- | apps/oauth2/lib/Migration/Version011603Date20230620111039.php | 6 |
4 files changed, 11 insertions, 11 deletions
diff --git a/apps/oauth2/lib/Controller/OauthApiController.php b/apps/oauth2/lib/Controller/OauthApiController.php index ecf0062918b..bb0f180bff9 100644 --- a/apps/oauth2/lib/Controller/OauthApiController.php +++ b/apps/oauth2/lib/Controller/OauthApiController.php @@ -126,15 +126,15 @@ class OauthApiController extends Controller { // check authorization code expiration $now = $this->timeFactory->now()->getTimestamp(); - $tokenCreatedAt = $accessToken->getCreatedAt(); - if ($tokenCreatedAt < $now - self::AUTHORIZATION_CODE_EXPIRES_AFTER) { + $codeCreatedAt = $accessToken->getCodeCreatedAt(); + if ($codeCreatedAt < $now - self::AUTHORIZATION_CODE_EXPIRES_AFTER) { // we know this token is not useful anymore $this->accessTokenMapper->delete($accessToken); $response = new JSONResponse([ 'error' => 'invalid_request', ], Http::STATUS_BAD_REQUEST); - $expiredSince = $now - self::AUTHORIZATION_CODE_EXPIRES_AFTER - $tokenCreatedAt; + $expiredSince = $now - self::AUTHORIZATION_CODE_EXPIRES_AFTER - $codeCreatedAt; $response->throttle(['invalid_request' => 'authorization_code_expired', 'expired_since' => $expiredSince]); return $response; } diff --git a/apps/oauth2/lib/Db/AccessToken.php b/apps/oauth2/lib/Db/AccessToken.php index 5fbfb87bc8b..1a31b4c2504 100644 --- a/apps/oauth2/lib/Db/AccessToken.php +++ b/apps/oauth2/lib/Db/AccessToken.php @@ -34,8 +34,8 @@ use OCP\AppFramework\Db\Entity; * @method void setEncryptedToken(string $token) * @method string getHashedCode() * @method void setHashedCode(string $token) - * @method int getCreatedAt() - * @method void setCreatedAt(int $createdAt) + * @method int getCodeCreatedAt() + * @method void setCodeCreatedAt(int $createdAt) * @method int getTokenCount() * @method void setTokenCount(int $tokenCount) */ @@ -49,7 +49,7 @@ class AccessToken extends Entity { /** @var string */ protected $encryptedToken; /** @var int */ - protected $createdAt; + protected $codeCreatedAt; /** @var int */ protected $tokenCount; @@ -59,7 +59,7 @@ class AccessToken extends Entity { $this->addType('clientId', 'int'); $this->addType('hashedCode', 'string'); $this->addType('encryptedToken', 'string'); - $this->addType('created_at', 'int'); + $this->addType('code_created_at', 'int'); $this->addType('token_count', 'int'); } } diff --git a/apps/oauth2/lib/Db/AccessTokenMapper.php b/apps/oauth2/lib/Db/AccessTokenMapper.php index c62fc4d2b5f..0347a43d7c6 100644 --- a/apps/oauth2/lib/Db/AccessTokenMapper.php +++ b/apps/oauth2/lib/Db/AccessTokenMapper.php @@ -99,7 +99,7 @@ class AccessTokenMapper extends QBMapper { $qb ->delete($this->tableName) ->where($qb->expr()->eq('token_count', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))) - ->andWhere($qb->expr()->lt('created_at', $qb->createNamedParameter($maxTokenCreationTs, IQueryBuilder::PARAM_INT))); + ->andWhere($qb->expr()->lt('code_created_at', $qb->createNamedParameter($maxTokenCreationTs, IQueryBuilder::PARAM_INT))); $qb->executeStatement(); } } diff --git a/apps/oauth2/lib/Migration/Version011603Date20230620111039.php b/apps/oauth2/lib/Migration/Version011603Date20230620111039.php index 06cc4db5ab3..02dd8a38aab 100644 --- a/apps/oauth2/lib/Migration/Version011603Date20230620111039.php +++ b/apps/oauth2/lib/Migration/Version011603Date20230620111039.php @@ -47,8 +47,8 @@ class Version011603Date20230620111039 extends SimpleMigrationStep { if ($schema->hasTable('oauth2_access_tokens')) { $table = $schema->getTable('oauth2_access_tokens'); $dbChanged = false; - if (!$table->hasColumn('created_at')) { - $table->addColumn('created_at', Types::BIGINT, [ + if (!$table->hasColumn('code_created_at')) { + $table->addColumn('code_created_at', Types::BIGINT, [ 'notnull' => true, 'default' => 0, ]); @@ -62,7 +62,7 @@ class Version011603Date20230620111039 extends SimpleMigrationStep { $dbChanged = true; } if (!$table->hasIndex('oauth2_tk_c_created_idx')) { - $table->addIndex(['token_count', 'created_at'], 'oauth2_tk_c_created_idx'); + $table->addIndex(['token_count', 'code_created_at'], 'oauth2_tk_c_created_idx'); $dbChanged = true; } if ($dbChanged) { |