作者:nordsoftwar
项目:lumen-oauth2-dynamod
/**
* @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;
}
作者:fahmiard
项目:oauth2-server-redi
/**
* 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']);
}
作者:nordsoftwar
项目:lumen-oauth
/**
* @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;
}
作者:koanrevie
项目:cribb
/**
* 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);
}
作者:tonis-i
项目:oauth
public function getByAccessToken(AccessTokenEntity $accessToken)
{
if ($accessToken->getId() !== 'foo') {
return null;
}
$session = new SessionEntity($this->server);
$session->setId('foo');
return $session;
}
作者:khalidnrgedg
项目:oauth2-server-larave
/**
* 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']);
}
作者:redaigbari
项目:oauth2-cloudan
/**
* 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);
}
作者:tonis-i
项目:oauth
public function get($token)
{
if ($token !== 'foo') {
return null;
}
$token = new AccessTokenEntity($this->server);
$token->setId('foo');
$token->setExpireTime(time() + 3600);
return $token;
}
作者:nordsoftwar
项目:lumen-oauth2-dynamod
/**
* @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);
}
作者:glgeorgie
项目:laravel-oauth2-serve
/**
* {@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;
}
作者:lizongyin
项目:thinkphp-oaut
/**
* {@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;
}
作者:avlim
项目:oauth2server-lume
/**
* {@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;
}
作者:serviceCuCu9
项目:PhalconOauth2RESTfulServe
/**
* 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;
}
作者:joshtroni
项目:pickle
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;
}
作者:bitExper
项目:oauth2-server-storage-dba
/**
* {@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;
}
}
作者:gobudgi
项目:gobudgi
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessTokenEntity)
{
/** @var AccessToken $accessToken */
$accessToken = $this->dm->getRepository(AccessToken::class)->find($accessTokenEntity->getId());
if ($accessToken === null) {
return null;
}
$session = $accessToken->getSession();
$sessionEntity = new SessionEntity($this->server);
$sessionEntity->setId($session->getId());
$sessionEntity->setOwner($session->getOwnerType(), $session->getOwnerId());
return $sessionEntity;
}
作者:fahmiard
项目:oauth2-server-storage-redi
/**
* {@inheritdoc}
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$key = RedisUtil::prefix($accessToken->getId(), 'oauth_access_tokens');
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']);
}
作者:laughingpai
项目:oauth-serve
/**
* {@inheritdoc}
*
* @param \League\OAuth2\Server\Entity\AccessTokenEntity $accessToken Access token
* @return \League\OAuth2\Server\Entity\SessionEntity
*/
public function getByAccessToken(AccessTokenEntity $accessToken)
{
$this->loadModel('OAuthServer.Sessions');
$result = $this->Sessions->find()->matching('AccessTokens', function ($q) use($accessToken) {
return $q->where(['oauth_token' => $accessToken->getId()]);
})->first();
if ($result) {
$session = new SessionEntity($this->server);
$session->setId($result->id);
$session->setOwner($result->owner_model, $result->owner_id);
return $session;
}
}
作者:wdalmu
项目:oauth2-server-redis-storag
public function testAssociateScope()
{
$redis = $this->prophesize("Corley\\OAuth2\\Server\\Storage\\Redis\\RedisMock");
$redis->lpush("access_token:scopes:access_token_id", "scope_id:desc")->shouldBeCalledTimes(1)->willReturn(null);
$server = $this->prophesize("League\\OAuth2\\Server\\AbstractServer");
$server->getEventEmitter()->willReturn(new Emitter());
$accessTokenStorage = new AccessTokenStorage($redis->reveal());
$accessTokenStorage->setServer($server->reveal());
$accessToken = new AccessTokenEntity($server->reveal());
$accessToken->setId("access_token_id");
$scope = new ScopeEntity($server->reveal());
$scope->hydrate(["id" => "scope_id", "description" => "desc"]);
$accessTokenStorage->associateScope($accessToken, $scope);
}
作者:ellipsesynergi
项目:backend-skeleto
public function testPutAndGetSessionByAccessToken()
{
$server = m::mock(AbstractServer::class);
$server->shouldReceive('getEventEmitter->emit')->once();
$session = new SessionEntity($server);
$session->setOwner('owner', 1);
$session->setId('id');
$accessToken = new AccessTokenEntity($server);
$accessToken->setId('my_token');
$accessToken->setExpireTime(1);
$this->cache->putSessionByAccessToken($accessToken, $session);
$session = $this->cache->getSessionByAccessToken('my_token');
$this->assertSame(['id' => 'id', 'owner_type' => 'owner', 'owner_id' => 1], $session);
}