/**
  * Delete an authorization code from Redis storage.
  * 
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity  $code
  * @return void
  */
 public function delete(AuthCodeEntity $code)
 {
     // Deletes the authorization code entry.
     $this->deleteKey($code->getId(), 'oauth_auth_codes');
     // Deletes the authorization code entry from the authorization codes set.
     $this->deleteSet(null, 'oauth_auth_codes', $code->getId());
     // Deletes the authorization codes associated scopes.
     $this->deleteKey($code->getId(), 'oauth_auth_code_scopes');
 }
 /**
  * Get a session from Redis storage by an associated authorization code.
  * 
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity  $authCode
  * @return \League\OAuth2\Server\Entity\SessionEntity|null
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     if (!($code = $this->getValue($authCode->getId(), 'oauth_auth_codes'))) {
         return null;
     }
     return $this->get($code['session_id']);
 }
Exemplo n.º 3
0
 /**
  * Get a session from an auth code
  *
  * @param AuthCodeEntity $authCode
  * @return SessionEntity
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = $this->db->table('oauth_sessions')->select('oauth_sessions.*')->join('oauth_auth_codes', 'oauth_sessions.id', '=', 'oauth_auth_codes.session_id')->where('oauth_auth_codes.id', $authCode->getId())->first();
     if (is_null($result)) {
         return;
     }
     return (new SessionEntity($this->getServer()))->setId($result->id)->setOwner($result->owner_type, $result->owner_id);
 }
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = DB::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;
 }
 /**
  * Get a session from an auth code
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code
  * @return \League\OAuth2\Server\Entity\SessionEntity
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = $this->db->fetchAll("SELECT s.id, s.owner_type, s.owner_id, s.client_id, s.client_redirect_uri FROM oauth_sessions s " . "JOIN oauth_auth_codes c ON c.session_id = s.id " . "WHERE c.auth_code = ?", Db::FETCH_ASSOC, [$authCode->getId()]);
     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;
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = $this->getConnection()->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())->first();
     if (!is_null($result)) {
         $session = new SessionEntity($this->server);
         $session->setId($result->id);
         $session->setOwner($result->owner_type, $result->owner_id);
         return $session;
     }
     return;
 }
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = M('oauth_sessions')->field('oauth_sessions.id, oauth_sessions.owner_type, oauth_sessions.owner_id, oauth_sessions.client_id, oauth_sessions.client_redirect_uri')->join('LEFT JOIN oauth_auth_codes ON oauth_auth_codes.session_id = oauth_sessions.id')->where(array('oauth_auth_codes.auth_code' => $authCode->getId()))->select();
     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;
 }
Exemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $result = app('db')->table('oauth_session')->select(['oauth_session.id', 'oauth_session.owner_type', 'oauth_session.owner_id', 'oauth_session.client_id', 'oauth_session.client_redirect_uri'])->join('oauth_auth_code', 'oauth_auth_code.session_id', '=', 'oauth_session.id')->where('oauth_auth_code.auth_code', $authCode->getId())->first();
     if (is_object($result)) {
         $session = new SessionEntity($this->server);
         $session->setId($result->id);
         $session->setOwner($result->owner_type, $result->owner_id);
         return $session;
     }
     return;
 }
Exemplo n.º 9
0
 public function getByAuthCode(AuthCodeEntity $auth_code)
 {
     $sql = 'SELECT oauth_sessions.id, oauth_sessions.owner_type,' . ' oauth_sessions.owner_id, oauth_sessions.client_id,' . ' oauth_sessions.client_redirect_uri' . ' FROM oauth_sessions' . ' INNER JOIN oauth_authorization_codes' . ' ON oauth_authorization_codes.session_id = oauth_sessions.id' . ' WHERE oauth_authorization_codes.authorization_code = ?;';
     $results = $this->db->fetch($sql, [$auth_code->getId()]);
     if (count($results) === 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;
 }
Exemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCodeEntity)
 {
     /** @var AuthCode $authCode */
     $authCode = $this->dm->getRepository(AuthCode::class)->find($authCodeEntity->getId());
     if ($authCode === null) {
         return null;
     }
     $session = $authCode->getSession();
     $sessionEntity = new SessionEntity($this->server);
     $sessionEntity->setId($session->getId());
     $sessionEntity->setOwner($session->getOwnerType(), $session->getOwnerId());
     return $sessionEntity;
 }
Exemplo n.º 11
0
 /**
  * {@inheritdoc}
  *
  * @param \League\OAuth2\Server\Entity\AuthCodeEntity $authCode Auth code
  * @return \League\OAuth2\Server\Entity\SessionEntity
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $this->loadModel('OAuthServer.Sessions');
     $result = $this->Sessions->find()->matching('AuthCodes', function ($q) use($authCode) {
         return $q->where(['code' => $authCode->getId()]);
     })->first();
     if ($result) {
         $session = new SessionEntity($this->server);
         $session->setId($result->id);
         $session->setOwner($result->owner_model, $result->owner_id);
         return $session;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $query = $this->db->createQueryBuilder()->select('s.id', 's.owner_type', 's.owner_id')->from('oauth_sessions', 's')->join('s', 'oauth_auth_codes', 'ac', 's.id = ac.session_id')->where('ac.auth_code = :authCode');
     $query->createNamedParameter($authCode->getId(), \PDO::PARAM_STR, ':authCode');
     $stmt = $query->execute();
     $result = $stmt->fetchAll();
     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;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $key = RedisUtil::prefix($authCode->getId(), 'oauth_auth_codes');
     if (isset($this->cache[$key])) {
         $result = $this->cache[$key];
     } else {
         if (!($value = RedisCapsule::get($key))) {
             return;
         }
         $result = $this->cache[$key] = RedisUtil::unserialize($value);
     }
     return $this->getSession($result['session_id']);
 }
Exemplo n.º 14
0
    /**
     * Get a session from an auth code
     *
     * @param \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code
     *
     * @return \League\OAuth2\Server\Entity\SessionEntity | null
     */
    public function getByAuthCode(AuthCodeEntity $authCode)
    {
        $sql = <<<SQL
SELECT os.id, os.owner_type, os.owner_id, os.client_id, os.client_redirect_uri
FROM oauth_session os
INNER JOIN oauth_auth_code oac ON(oac.session_id = os.id)
WHERE oac.auth_code = :authCode
SQL;
        foreach ($this->getDbConnection()->fetchAll($sql, ['authCode' => $authCode->getId()]) as $row) {
            if ($row) {
                return (new SessionEntity($this->server))->setId($row['id'])->setOwner($row['owner_type'], $row['owner_id']);
            }
        }
        return null;
    }
Exemplo n.º 15
0
 /**
  * Get a session from an auth code
  *
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code
  *
  * @return SessionEntity
  * @throws OAuthException
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $querySessions = new Query();
     $session = null;
     $sessionResult = $querySessions->select(['{{%oauth_sessions}}.id as id', '{{%oauth_sessions}}.owner_type as owner_type', '{{%oauth_sessions}}.owner_id as owner_id', '{{%oauth_sessions}}.client_id as client_id', '{{%oauth_sessions}}.client_redirect_uri as redirect_uri'])->from('{{%oauth_sessions}}')->innerJoin('oauth_auth_codes', '{{%oauth_auth_codes}}.session_id={{%oauth_sessions}}.id')->where(['{{%oauth_auth_codes}}.auth_code' => $authCode->getId()])->one();
     if ($sessionResult) {
         $session = new SessionEntity($this->getServer());
         $session->setId($sessionResult['id']);
         $session->setOwner($sessionResult['owner_type'], $sessionResult['owner_id']);
         if (!$session->save()) {
             throw new OAuthException(json_encode($session->errors));
         }
     } else {
         throw new OAuthException(json_encode($sessionResult));
     }
     return $session;
 }
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $rawData = $this->redis->get("auth_code:{$authCode->getId()}");
     if (!$rawData) {
         return null;
     }
     $data = json_decode($rawData, true);
     $sessionId = $data['session_id'];
     $rawData = $this->redis->get("session:{$data["session_id"]}");
     if (!$rawData) {
         return null;
     }
     $data = json_decode($rawData, true);
     $session = new SessionEntity($this->server);
     $session->setId($sessionId);
     $session->setOwner($data['owner_type'], $data['owner_id']);
     return $session;
 }
 /**
  * {@inheritdoc}
  */
 public function delete(AuthCodeEntity $token)
 {
     M('oauth_auth_codes')->where(array('auth_code' => $token->getId()))->delete();
 }
Exemplo n.º 18
0
 /**
  * Delete an access token
  *
  * @param AuthCodeEntity $token
  * @return void
  */
 public function delete(AuthCodeEntity $token)
 {
     $this->db->table('oauth_auth_codes')->where('oauth_auth_codes.id', $token->getId())->delete();
 }
 /**
  * Delete an access token
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity $token The access token to delete
  * @return void
  */
 public function delete(AuthCodeEntity $token)
 {
     $this->db->delete("oauth_auth_codes", "auth_code = ?", [$token->getId()]);
 }
 /**
  * {@inheritdoc}
  */
 public function delete(AuthCodeEntity $token)
 {
     // // Deletes the authorization code entry.
     $key = RedisUtil::prefix($token->getId(), 'oauth_auth_codes');
     if (isset($this->cache[$key])) {
         unset($this->cache[$key]);
     }
     RedisCapsule::del($key);
     // // Deletes the authorization code entry from the authorization codes set.
     $key = RedisUtil::prefix(null, 'oauth_auth_codes');
     if (isset($this->cache[$key]) && ($cacheKey = array_search($token->getId(), $this->cache[$key])) !== false) {
         unset($this->cache[$key][$cacheKey]);
     }
     RedisCapsule::srem($key, $token->getId());
     // // Deletes the authorization codes associated scopes.
     $key = RedisUtil::prefix($token->getId(), 'oauth_auth_code_scopes');
     if (isset($this->cache[$key])) {
         unset($this->cache[$key]);
     }
     RedisCapsule::del($key);
 }
Exemplo n.º 21
0
 /**
  * {@inheritdoc}
  */
 public function delete(AuthCodeEntity $token)
 {
     Capsule::table('oauth_auth_codes')->where('auth_code', $token->getId())->delete();
 }
Exemplo n.º 22
0
 /**
  * Delete an access token
  *
  * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The access token to delete
  *
  * @return void
  */
 public function delete(AuthCodeEntity $token)
 {
     $this->getDbConnection()->delete('oauth_auth_code_scope', ['auth_code' => $token->getId()]);
     $this->getDbConnection()->delete('oauth_auth_code', ['auth_code' => $token->getId()]);
 }
Exemplo n.º 23
0
 /**
  * {@inheritdoc}
  */
 public function delete(AuthCodeEntity $token)
 {
     app('db')->table('oauth_auth_code')->where('auth_code', $token->getId())->delete();
 }
Exemplo n.º 24
0
 /**
  * {@inheritdoc}
  */
 public function delete(AuthCodeEntity $token)
 {
     $this->loadModel('OAuthServer.AuthCodes');
     $this->AuthCodes->deleteAll(['code' => $token->getId()]);
 }
 /**
  * Get a session from an auth code
  * @param  \League\OAuth2\Server\Entity\AuthCodeEntity $authCode The auth code
  * @return \League\OAuth2\Server\Entity\SessionEntity
  */
 public function getByAuthCode(AuthCodeEntity $authCode)
 {
     $allowedSessionIds = $this->getConnection()->table('oauth_auth_codes')->where('id', $authCode->getId())->pluck('session_id');
     $result = $this->getConnection()->table('oauth_sessions')->whereIn('id', $allowedSessionIds)->first();
     if (is_null($result)) {
         return null;
     }
     return (new SessionEntity($this->getServer()))->setId($result['id'])->setOwner($result['owner_type'], $result['owner_id']);
 }
 /**
  * Delete an access token.
  *
  * @param \League\OAuth2\Server\Entity\AuthCodeEntity $token The access token to delete
  */
 public function delete(AuthCodeEntity $token)
 {
     $this->getConnection()->table('oauth_auth_codes')->where('id', $token->getId())->delete();
     $this->getConnection()->table('oauth_auth_code_scopes')->where('auth_code_id', $token->getId())->delete();
 }