本文整理汇总了PHP中League\OAuth2\Server\Entity\AccessTokenEntity类的典型用法代码示例。如果您正苦于以下问题:PHP AccessTokenEntity类的具体用法?PHP AccessTokenEntity怎么用?PHP AccessTokenEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AccessTokenEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEntity
/**
* @param AccessToken $accessToken
*
* @return AccessTokenEntity
*/
protected function createEntity(AccessToken $accessToken)
{
$entity = new AccessTokenEntity($this->server);
$entity->setId($accessToken->token);
$entity->setExpireTime(Carbon::createFromFormat('Y-m-d H:i:s', $accessToken->expireTime)->getTimestamp());
return $entity;
}
示例2: getByAccessToken
/**
* Get a session from Redis storage by an associated access token.
*
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken
* @return \League\OAuth2\Server\Entity\SessionEntity|null
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
if (!($token = $this->getValue($accessToken->getToken(), 'oauth_access_tokens'))) {
return null;
}
return $this->get($token['session_id']);
}
示例3: get
/**
* @inheritdoc
*/
public function get($token)
{
$entity = new AccessTokenEntity($this->server);
$entity->setId('mF_9.B5f-4.1JqM');
$entity->setExpireTime(time() + 24 * 60 * 60);
// NOW + 24h
return $entity;
}
示例4: getByAccessToken
/**
* Get a session from an access token
*
* @param AccessTokenEntity $accessToken
* @return SessionEntity
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$result = $this->db->table('oauth_sessions')->select('oauth_sessions.*')->join('oauth_access_tokens', 'oauth_sessions.id', '=', 'oauth_access_tokens.session_id')->where('oauth_access_tokens.id', $accessToken->getId())->first();
if (is_null($result)) {
return;
}
return (new SessionEntity($this->getServer()))->setId($result->id)->setOwner($result->owner_type, $result->owner_id);
}
示例5: getByAccessToken
public function getByAccessToken(AccessTokenEntity $accessToken)
{
if ($accessToken->getId() !== 'foo') {
return null;
}
$session = new SessionEntity($this->server);
$session->setId('foo');
return $session;
}
示例6: getByAccessToken
/**
* Get a session from an access token
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The access token
* @return \League\OAuth2\Server\Entity\SessionEntity
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$allowedSessionIds = $this->getConnection()->table('oauth_access_tokens')->where('id', $accessToken->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']);
}
示例7: getByAccessToken
/**
* Get a session from an access token.
*
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The access token
*
* @return \League\OAuth2\Server\Entity\SessionEntity
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$result = Config::get('couch.client')->useDatabase('oauth_sessions')->getDoc($accessToken->getSessionId());
if (is_null($result)) {
return;
}
config('session', $result);
return (new SessionEntity($this->getServer()))->setId($result->_id)->setOwner($result->owner_type, $result->owner_id);
}
示例8: get
public function get($token)
{
if ($token !== 'foo') {
return null;
}
$token = new AccessTokenEntity($this->server);
$token->setId('foo');
$token->setExpireTime(time() + 3600);
return $token;
}
示例9: getByAccessToken
/**
* @inheritdoc
*/
public function getByAccessToken(AccessTokenEntity $entity)
{
$accessToken = AccessToken::findByToken($entity->getId());
/** @var Session $session */
$session = Session::find($accessToken->sessionId);
if ($session === null) {
throw new SessionNotFound();
}
return $this->createEntity($session);
}
示例10: getByAccessToken
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$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_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id')->where('oauth_access_tokens.access_token', $accessToken->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;
}
示例11: getByAccessToken
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$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_access_tokens ON oauth_access_tokens.session_id = oauth_sessions.id')->where(array('oauth_access_tokens.access_token' => $accessToken->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;
}
示例12: getByAccessToken
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$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_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id')->where('oauth_access_tokens.access_token', $accessToken->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;
}
示例13: getByAccessToken
/**
* Get a session from an access token
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken The access token
* @return \League\OAuth2\Server\Entity\SessionEntity
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$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_access_tokens t ON t.session_id = s.id " . "WHERE t.access_token = ?", Db::FETCH_ASSOC, [$accessToken->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;
}
示例14: getByAccessToken
public function getByAccessToken(AccessTokenEntity $access_token)
{
$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_access_tokens' . ' ON oauth_access_tokens.session_id = oauth_sessions.id' . ' WHERE oauth_access_tokens.access_token = ?;';
$results = $this->db->fetch($sql, [$access_token->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;
}
示例15: getByAccessToken
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$query = $this->db->createQueryBuilder()->select('s.id', 's.owner_type', 's.owner_id')->from('oauth_sessions', 's')->join('s', 'oauth_access_tokens', 'at', 's.id = at.session_id')->where('at.access_token = :accessToken');
$query->createNamedParameter($accessToken->getId(), \PDO::PARAM_STR, ':accessToken');
$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;
}
}