getSession()?->account; } /** * @return string[] */ public function getAssignedPermissions(): array { return $this->scopes; } public function getId(): string { return $this->accessToken; } /** @codeCoverageIgnoreStart */ public function getAuthKey() { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } public function validateAuthKey($authKey) { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } public static function findIdentity($id) { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } /** @codeCoverageIgnoreEnd */ private static function findRecordOnLegacyStorage(string $accessToken): ?array { $record = Yii::$app->redis->get("oauth:access:tokens:{$accessToken}"); if ($record === null) { return null; } try { $data = json_decode((string)$record, true, 512, JSON_THROW_ON_ERROR); } catch (Exception) { return null; } $data['scopes'] = (array)Yii::$app->redis->smembers("oauth:access:tokens:{$accessToken}:scopes"); return $data; } private function getSession(): ?OauthSession { return OauthSession::findOne(['legacy_id' => $this->sessionId]); } }