/** * @inheritdoc */ public function getBySession(SessionEntity $entity) { $client = Client::findBySessionId($entity->getId()); if ($client === null) { throw new ClientNotFound(); } return $this->createEntity($client); }
/** * Get the client associated with a session * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * @return null|\League\OAuth2\Server\Entity\ClientEntity */ public function getBySession(SessionEntity $session) { $result = $this->getConnection()->table('oauth_clients')->select('oauth_clients.id as id', 'oauth_clients.secret as secret', 'oauth_clients.name as name')->join('oauth_sessions', 'oauth_sessions.client_id', '=', 'oauth_clients.id')->where('oauth_sessions.id', '=', $session->getId())->first(); if (is_null($result)) { return null; } return $this->hydrateEntity($result); }
/** * 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} */ public function getBySession(SessionEntity $sessionEntity) { /** @var Session $session */ $session = $this->dm->getRepository(Session::class)->find($sessionEntity->getId()); if ($session && $session->getClientId() === $this->clientId) { return (new ClientEntity($this->server))->hydrate(['id' => $this->clientId]); } return null; }
/** * {@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; }
/** * {@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 = 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; }
/** * Get the client associated with a session * * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * * @return \League\OAuth2\Server\Entity\ClientEntity */ public function getBySession(SessionEntity $session) { $client = null; $clientStorageQueryBuilder = new Query(); $clientBySessionResult = $clientStorageQueryBuilder->select("{{%oauth_clients}}.id, {{%oauth_clients}}.name")->from("{{%oauth_clients}}")->innerJoin("{{%oauth_sessions}}", "{{%oauth_clients}}.id={{%oauth_sessions}}.client_id")->where(["{{%oauth_sessions}}.id" => $session->getId()])->one(); if (count($clientBySessionResult) === 1) { $client = (new ClientEntity($this->server))->hydrate(['id' => $clientBySessionResult[0]['id'], 'name' => $clientBySessionResult[0]['name']]); } 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; } }
/** * Get the complete client data associated with a session * * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * * @return \League\OAuth2\Server\Entity\ClientEntity | null */ public function getCompleteBySession(SessionEntity $session) { $result = app('db')->table('oauth_client')->select(['oauth_client.id', 'oauth_client.secret', 'oauth_client.name', 'oauth_client_redirect_uri.redirect_uri', 'oauth_client.request_limit', 'oauth_client.current_total_request', 'oauth_client.request_limit_until', 'oauth_client.last_request_at'])->join('oauth_session', 'oauth_client.id', '=', 'oauth_session.client_id')->join('oauth_client_redirect_uri', 'oauth_client.id', '=', 'oauth_client_redirect_uri.client_id')->where('oauth_session.id', $session->getId())->first(); if (is_object($result)) { $client = new ClientEntity($this->server); $client->hydrate(['id' => $result->id, 'secret' => $result->secret, 'name' => $result->name, 'redirectUri' => $result->redirect_uri, 'requestLimit' => $result->request_limit, 'currentTotalRequest' => $result->current_total_request, 'requestLimitUntil' => $result->request_limit_until, 'lastRequestAt' => $result->last_request_at]); return $client; } return; }
/** * 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) { foreach ($this->getDbConnection()->fetchAll('SELECT oc.id, oc.name FROM oauth_client oc INNER JOIN oauth_session os ON(oc.id = os.client_id) WHERE os.id = :id', ['id' => $session->getId()]) as $row) { if ($row) { return (new ClientEntity($this->server))->hydrate(['id' => $row['id'], 'name' => $row['name']]); } } return null; }
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; } }
/** * {@inheritdoc} */ public function getBySession(SessionEntity $session) { $key = RedisUtil::prefix($session->getId(), 'oauth_sessions'); 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->get($result['client_id']); }
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; }
/** * {@inheritdoc} */ public function associateScope(SessionEntity $sessionEntity, ScopeEntity $scope) { /** @var Session $session */ $session = $this->dm->getRepository(Session::class)->find($sessionEntity->getId()); /** @var Scope $scope */ $scope = $this->dm->getRepository(Scope::class)->find($scope->getId()); $session->associateScope($scope); $this->dm->persist($session); $this->dm->flush($session); }
/** * @param $accessToken $accessToken * @param SessionEntity $session */ public function putSessionByAccessToken(AccessTokenEntity $accessToken, SessionEntity $session) { $this->cache->tags([$this->createTagKey([static::CACHE_NAMESPACE, 'sessions'])])->put($this->createKey(['access-token', $accessToken->getId()]), serialize(['id' => $session->getId(), 'owner_type' => $session->getOwnerType(), 'owner_id' => $session->getOwnerId()]), $this->ttl); }
/** * Associate a scope with a session * * @param SessionEntity $session * @param ScopeEntity $scope * @return void */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->db->table('oauth_session_scopes')->insert(['session_id' => $session->getId(), 'scope_id' => $scope->getId(), 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]); }
public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->redis->lpush("session:scopes:{$session->getId()}", "{$scope->getId()}:{$scope->getDescription()}"); }
/** * {@inheritdoc} */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $query = $this->db->createQueryBuilder()->insert('oauth_session_scopes')->values(['session_id' => ':token', 'scope' => ':scope']); $query->createNamedParameter($session->getId(), \PDO::PARAM_STR, ':token'); $query->createNamedParameter($scope->getId(), \PDO::PARAM_STR, ':scope'); $query->execute(); }
/** * Associate a scope with a session in Redis storage. * * @param \League\OAuth2\Server\Entity\SessionEntity $session * @param \League\OAuth2\Server\Entity\ScopeEntity $scope * @return void */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->pushSet($session->getId(), 'oauth_session_scopes', ['id' => $scope->getId()]); }
/** * Associate a scope with a session * @param \League\OAuth2\Server\Entity\SessionEntity $scope The scope * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope * @return void */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->db->insert("oauth_session_scopes", [$session->getId(), $scope->getId()], ['session_id', 'scope']); }
/** * Get the client associated with a session * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * @return null|\League\OAuth2\Server\Entity\ClientEntity */ public function getBySession(SessionEntity $session) { $allowedClientIds = $this->getConnection()->table('oauth_sessions')->where('id', $session->getId())->pluck('client_id'); $result = $this->getConnection()->table('oauth_clients')->whereIn('id', '=', $allowedClientIds)->first(); if (is_null($result)) { return null; } return $this->hydrateEntity($result); }
/** * {@inheritdoc} * * @param \League\OAuth2\Server\Entity\SessionEntity $session Session entity * @param \League\OAuth2\Server\Entity\ScopeEntity $scope Scope entity * @return void */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->loadModel('OAuthServer.SessionScopes'); $sessionScope = $this->SessionScopes->newEntity(['session_id' => $session->getId(), 'scope_id' => $scope->getId()]); $this->SessionScopes->save($sessionScope); }
/** * {@inheritdoc} */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { M('oauth_session_scopes')->add(array('session_id' => $session->getId(), 'scope' => $scope->getId())); }
/** * {@inheritdoc} */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $this->getConnection()->table('oauth_session_scopes')->insert(['session_id' => $session->getId(), 'scope' => $scope->getId()]); }
/** * Associate a scope with a session * * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * @param \League\OAuth2\Server\Entity\ScopeEntity $scope The scope * * @return null|string * @throws OAuthException */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { $sessionScopesStorage = new SessionScopesStorage(); $sessionScopesStorage->setAttribute("session_id", $session->getId()); $sessionScopesStorage->setAttribute("scope", $scope->getId()); if ($sessionScopesStorage->save()) { return $sessionScopesStorage->getPrimaryKey(); } else { throw new OAuthException(json_encode($sessionScopesStorage->errors)); } }
/** * {@inheritdoc} */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { Capsule::table('oauth_session_scopes')->insert(['session_id' => $session->getId(), 'scope' => $scope->getId()]); }
public function associateScope(SessionEntity $session, ScopeEntity $scope) { $sql = 'INSERT INTO oauth_access_token_scopes' . ' (access_token_id, scope_id)' . ' VALUES' . ' (?, ?);'; $this->db->execute($sql, [$session->getId(), $scope->getId()]); }
/** * Get the client associated with a session. * * @param \League\OAuth2\Server\Entity\SessionEntity $session The session * * @return null|\League\OAuth2\Server\Entity\ClientEntity */ public function getBySession(SessionEntity $session) { $result = $this->getConnection()->table('oauth_sessions')->where('_id', $session->getId())->first(); if (is_null($result)) { return; } $result = $this->getConnection()->table('oauth_clients')->where('id', $result['client_id'])->first(); if (is_null($result)) { return; } return $this->hydrateEntity($result); }