Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
 {
     $client = new ClientEntity($this->server);
     $client->hydrate(['id' => 'testclient', 'name' => 'Test Client']);
     return $client;
     // $query = Capsule::table('oauth_clients')
     //                   ->select('oauth_clients.*')
     //                   ->where('oauth_clients.id', $clientId);
     // if ($clientSecret !== null) {
     //     $query->where('oauth_clients.secret', $clientSecret);
     // }
     // if ($redirectUri) {
     //     $query->join('oauth_client_redirect_uris', 'oauth_clients.id', '=', 'oauth_client_redirect_uris.client_id')
     //           ->select(['oauth_clients.*', 'oauth_client_redirect_uris.*'])
     //           ->where('oauth_client_redirect_uris.redirect_uri', $redirectUri);
     // }
     // $result = $query->get();
     // if (count($result) === 1) {
     //     $client = new ClientEntity($this->server);
     //     $client->hydrate([
     //         'id'    =>  $result[0]['id'],
     //         'name'  =>  $result[0]['name'],
     //     ]);
     //     return $client;
     // }
     // return;
 }
Esempio n. 2
0
 /**
  * Get the client associated with a session
  *
  * @param \League\OAuth2\Server\Entity\SessionEntity $session The session
  *
  * @return \League\OAuth2\Server\Entity\ClientEntity | null
  */
 public function getBySession(SessionEntity $session)
 {
     if ($session->getId() !== 'foo') {
         return null;
     }
     $client = new ClientEntity($this->server);
     $client->hydrate(['id' => 'foo']);
     return $client;
 }
 /**
  * {@inheritdoc}
  *
  * @param \League\OAuth2\Server\Entity\SessionEntity $session Session entity
  * @return \League\OAuth2\Server\Entity\ClientEntity
  */
 public function getBySession(SessionEntity $session)
 {
     $this->loadModel('OAuthServer.Sessions');
     $result = $this->Sessions->find()->contain(['Clients'])->where(['Sessions.id' => $session->getId()])->first();
     if ($result) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result->client->id, 'name' => $result->client->name]);
         return $client;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getBySession(SessionEntity $session)
 {
     $result = M('oauth_clients')->field('oauth_clients.id, oauth_clients.name')->join('LEFT JOIN oauth_sessions ON oauth_clients.id = oauth_sessions.client_id')->where(array('oauth_sessions.id' => $session->getId()))->select();
     if (count($result) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result[0]['id'], 'name' => $result[0]['name']]);
         return $client;
     }
     return;
 }
 /**
  * {@inheritdoc}
  */
 public function getBySession(SessionEntity $session)
 {
     $result = Capsule::table('oauth_clients')->select(['oauth_clients.id', 'oauth_clients.name'])->join('oauth_sessions', 'oauth_clients.id', '=', 'oauth_sessions.client_id')->where('oauth_sessions.id', $session->getId())->get();
     if (count($result) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result[0]['id'], 'name' => $result[0]['name']]);
         return $client;
     }
     return;
 }
 /**
  * {@inheritdoc}
  */
 public function getBySession(SessionEntity $session)
 {
     $result = $this->db->fetchAll("SELECT c.id, c.name FROM oauth_clients c JOIN oauth_sessions s ON c.id = s.client_id WHERE s.id = ?", Db::FETCH_ASSOC, [$session->getId()]);
     if (count($result) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result[0]['id'], 'name' => $result[0]['name']]);
         return $client;
     }
     return NULL;
 }
Esempio n. 7
0
 public function getBySession(SessionEntity $session)
 {
     $sql = 'SELECT oauth_clients.id, oauth_clients.name' . ' FROM oauth_clients' . ' INNER JOIN oauth_sessions' . ' ON oauth_clients.id = oauth_sessions.client_id' . ' WHERE oauth_sessions.id = ?';
     $results = $this->db->fetch($sql, [$session->getId()]);
     if (count($results) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $results[0]['id'], 'name' => $results[0]['name']]);
         return $client;
     }
     return null;
 }
 /**
  * {@inheritdoc}
  */
 public function getBySession(SessionEntity $session)
 {
     $query = $this->db->createQueryBuilder()->select('c.id', 'c.name')->from('oauth_clients', 'c')->leftJoin('c', 'oauth_sessions', 's', 'c.id = s.client_id')->where('s.id = :sessionId');
     $query->createNamedParameter($session->getId(), \PDO::PARAM_STR, ':sessionId');
     $stmt = $query->execute();
     $result = $stmt->fetchAll();
     if (count($result) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result[0]['id'], 'name' => $result[0]['name']]);
         return $client;
     }
 }
 public function getBySession(SessionEntity $session)
 {
     $rawData = $this->redis->get("session:{$session->getId()}");
     if ($rawData === null) {
         return null;
     }
     $data = json_decode($rawData, true);
     $rawData = $this->redis->get("client:{$data["client_id"]}");
     if ($rawData === null) {
         return null;
     }
     $data = json_decode($rawData, true);
     $entity = new ClientEntity($this->server);
     $entity->hydrate(["id" => $data["client_id"], "name" => $data["name"]]);
     return $entity;
 }
Esempio n. 10
0
 public function get($clientId, $clientSecret = null, $redirectUri = null, $grantType = null)
 {
     $query = App::where('id', '=', $clientId);
     if ($clientSecret !== null) {
         $query->where('secret', '=', $clientSecret);
     }
     if ($redirectUri) {
         $query->where('redirect_uri', '=', $redirectUri);
     }
     $result = $query->get();
     if (count($result) === 1) {
         $client = new ClientEntity($this->server);
         $client->hydrate(['id' => $result[0]['id'], 'name' => $result[0]['name']]);
         return $client;
     }
     return;
 }
Esempio n. 11
0
 /**
  * Hydrate the entity.
  *
  * @param $result
  *
  * @return \League\OAuth2\Server\Entity\ClientEntity
  */
 protected function hydrateEntity($result)
 {
     $client = new ClientEntity($this->getServer());
     $client->hydrate(['id' => $result->_id, 'name' => $result->name, 'secret' => $result->secret, 'redirectUri' => isset($result->redirect_uri) ? $result->redirect_uri : null]);
     return $client;
 }
 /**
  * @param Client $client
  *
  * @return \League\OAuth2\Server\Entity\ClientEntity
  */
 protected function createEntity(Client $client)
 {
     $entity = new ClientEntity($this->server);
     $entity->hydrate(['id' => $client->key, 'name' => $client->name]);
     return $entity;
 }
 /**
  * @inheritdoc
  */
 public function getBySession(SessionEntity $entity)
 {
     $entity = new ClientEntity($this->server);
     $entity->hydrate(['id' => 'test', 'name' => 'test']);
     return $entity;
 }