本文整理汇总了PHP中League\OAuth2\Server\Entity\AccessTokenEntity类的典型用法代码示例。如果您正苦于以下问题:PHP AccessTokenEntity类的具体用法?PHP AccessTokenEntity怎么用?PHP AccessTokenEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AccessTokenEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:nordsoftware,项目名称:lumen-oauth2-dynamodb,代码行数:12,代码来源:AccessTokenStorage.php
示例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']);
}
开发者ID:fahmiardi,项目名称:oauth2-server-redis,代码行数:13,代码来源:RedisSession.php
示例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;
}
开发者ID:nordsoftware,项目名称:lumen-oauth2,代码行数:11,代码来源:MockAccessTokenStorage.php
示例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);
}
开发者ID:koanreview,项目名称:cribbb,代码行数:14,代码来源:SessionStorage.php
示例5: getByAccessToken
public function getByAccessToken(AccessTokenEntity $accessToken)
{
if ($accessToken->getId() !== 'foo') {
return null;
}
$session = new SessionEntity($this->server);
$session->setId('foo');
return $session;
}
开发者ID:tonis-io,项目名称:oauth2,代码行数:9,代码来源:SessionStorage.php
示例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']);
}
开发者ID:khalidnrgedge,项目名称:oauth2-server-laravel,代码行数:14,代码来源:FluentSession.php
示例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);
}
开发者ID:redaigbaria,项目名称:oauth2-cloudant,代码行数:16,代码来源:FluentSession.php
示例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;
}
开发者ID:tonis-io,项目名称:oauth2,代码行数:10,代码来源:AccessTokenStorage.php
示例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);
}
开发者ID:nordsoftware,项目名称:lumen-oauth2-dynamodb,代码行数:13,代码来源:SessionStorage.php
示例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;
}
开发者ID:glgeorgiev,项目名称:laravel-oauth2-server,代码行数:14,代码来源:SessionStorage.php
示例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;
}
开发者ID:lizongying,项目名称:thinkphp-oauth,代码行数:14,代码来源:SessionStorage.class.php
示例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;
}
开发者ID:avlima,项目名称:oauth2server-lumen,代码行数:14,代码来源:SessionStorage.php
示例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;
}
开发者ID:serviceCuCu91,项目名称:PhalconOauth2RESTfulServer,代码行数:16,代码来源:Session.php
示例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;
}
开发者ID:joshtronic,项目名称:pickles,代码行数:12,代码来源:SessionStorage.php
示例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;
}
}
开发者ID:bitExpert,项目名称:oauth2-server-storage-dbal,代码行数:16,代码来源:SessionStorage.php
示例16: getByAccessToken
/**
* {@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;
}
开发者ID:gobudgit,项目名称:gobudgit,代码行数:16,代码来源:SessionStorage.php
示例17: getByAccessToken
/**
* {@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']);
}
开发者ID:fahmiardi,项目名称:oauth2-server-storage-redis,代码行数:16,代码来源:RedisSession.php
示例18: getByAccessToken
/**
* {@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;
}
}
开发者ID:laughingpain,项目名称:oauth-server,代码行数:19,代码来源:SessionStorage.php
示例19: testAssociateScope
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);
}
开发者ID:wdalmut,项目名称:oauth2-server-redis-storage,代码行数:14,代码来源:AccessTokenStorageTest.php
示例20: testPutAndGetSessionByAccessToken
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);
}
开发者ID:ellipsesynergie,项目名称:backend-skeleton,代码行数:14,代码来源:Oauth2CacheTest.php
注:本文中的League\OAuth2\Server\Entity\AccessTokenEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论