当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::addStorage方法代码示例

本文整理汇总了PHP中OAuth2\Server::addStorage方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::addStorage方法的具体用法?PHP Server::addStorage怎么用?PHP Server::addStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth2\Server的用法示例。


在下文中一共展示了Server::addStorage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: middleware

 public function middleware($req, $res)
 {
     $this->app['oauth_server'] = function ($c) {
         $storage = new IdealistStorage();
         $storage->injectApp($c);
         $server = new Server($storage);
         // password grant type
         $grantType = new UserCredentials($storage);
         $server->addGrantType($grantType);
         // JWT access token response type
         $config = $c['config']->get('oauth2');
         $jwtResponseType = new JwtAccessToken($storage, $storage, null, $config);
         $server->addResponseType($jwtResponseType);
         return $server;
     };
     $this->app['oauth_resource'] = function ($c) {
         $server = new Server();
         // no private key is necessary for the resource server
         $keyStorage = new Memory(['keys' => ['public_key' => file_get_contents(INFUSE_BASE_DIR . '/jwt_pubkey.pem')]]);
         $storage = new JwtAccessTokenStorage($keyStorage);
         $server->addStorage($storage, 'access_token');
         return $server;
     };
     // attempt to authenticate the user when an API request is made
     if ($req->isApi()) {
         $this->authenticateApiRequest();
     }
 }
开发者ID:idealistsoft,项目名称:framework-oauth2,代码行数:28,代码来源:Controller.php

示例2: setup

 /**
  * function to create the OAuth2 Server Object
  */
 public function setup(Application $app)
 {
     // ensure our Sqlite database exists
     if (!file_exists($sqliteFile = __DIR__ . '/../../../data/oauth.sqlite')) {
         $this->generateSqliteDb();
     }
     // create PDO-based sqlite storage
     $storage = new Pdo(array('dsn' => 'sqlite:' . $sqliteFile));
     // create array of supported grant types
     $grantTypes = array('authorization_code' => new AuthorizationCode($storage), 'user_credentials' => new UserCredentials($storage), 'refresh_token' => new RefreshToken($storage, array('always_issue_new_refresh_token' => true)));
     // instantiate the oauth server
     $server = new OAuth2Server($storage, array('enforce_state' => true, 'allow_implicit' => true, 'use_openid_connect' => true, 'issuer' => $_SERVER['HTTP_HOST']), $grantTypes);
     $server->addStorage($this->getKeyStorage(), 'public_key');
     // add the server to the silex "container" so we can use it in our controllers (see src/OAuth2Demo/Server/Controllers/.*)
     $app['oauth_server'] = $server;
     /**
      * add HttpFoundataionBridge Response to the container, which returns a silex-compatible response object
      * @see (https://github.com/bshaffer/oauth2-server-httpfoundation-bridge)
      */
     $app['oauth_response'] = new BridgeResponse();
 }
开发者ID:hachi-zzq,项目名称:oauth2-demo-php,代码行数:24,代码来源:Server.php

示例3: testUsingJwtAccessTokensWithoutPublicKeyStorageThrowsException

 /**
  * @expectedException LogicException OAuth2\Storage\PublicKeyInterface
  **/
 public function testUsingJwtAccessTokensWithoutPublicKeyStorageThrowsException()
 {
     $server = new Server(array(), array('use_jwt_access_tokens' => true));
     $server->addGrantType($this->getMock('OAuth2\\GrantType\\GrantTypeInterface'));
     $server->addStorage($this->getMock('OAuth2\\Storage\\ClientCredentialsInterface'));
     $server->addStorage($this->getMock('OAuth2\\Storage\\ClientCredentialsInterface'));
     $server->getTokenController();
 }
开发者ID:huangzhwork,项目名称:oauth2-server-php,代码行数:11,代码来源:ServerTest.php

示例4: testAddingResponseType

 public function testAddingResponseType()
 {
     $storage = $this->getMock('OAuth2\\Storage\\Memory');
     $storage->expects($this->any())->method('getClientDetails')->will($this->returnValue(array('client_id' => 'some_client')));
     $storage->expects($this->any())->method('checkRestrictedGrantType')->will($this->returnValue(true));
     // add with the "code" key explicitly set
     $codeType = new AuthorizationCode($storage);
     $server = new Server();
     $server->addStorage($storage);
     $server->addResponseType($codeType);
     $request = new Request(array('response_type' => 'code', 'client_id' => 'some_client', 'redirect_uri' => 'http://example.com', 'state' => 'xyx'));
     $server->handleAuthorizeRequest($request, $response = new Response(), true);
     // the response is successful
     $this->assertEquals($response->getStatusCode(), 302);
     $parts = parse_url($response->getHttpHeader('Location'));
     parse_str($parts['query'], $query);
     $this->assertTrue(isset($query['code']));
     $this->assertFalse(isset($query['error']));
     // add with the "code" key not set
     $codeType = new AuthorizationCode($storage);
     $server = new Server(array($storage), array(), array(), array($codeType));
     $request = new Request(array('response_type' => 'code', 'client_id' => 'some_client', 'redirect_uri' => 'http://example.com', 'state' => 'xyx'));
     $server->handleAuthorizeRequest($request, $response = new Response(), true);
     // the response is successful
     $this->assertEquals($response->getStatusCode(), 302);
     $parts = parse_url($response->getHttpHeader('Location'));
     parse_str($parts['query'], $query);
     $this->assertTrue(isset($query['code']));
     $this->assertFalse(isset($query['error']));
 }
开发者ID:sarfraznawaz2005,项目名称:sso-examples,代码行数:30,代码来源:ServerTest.php


注:本文中的OAuth2\Server::addStorage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。