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


PHP Authorization::withRequiredScope方法代码示例

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


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

示例1: callWithEitherScope

 /**
  * Verify call with scopes using OR logic
  *
  * @test
  * @covers ::call
  *
  * @return void
  */
 public function callWithEitherScope()
 {
     $storage = new \OAuth2\Storage\Memory(['access_tokens' => ['atokenvalue' => ['access_token' => 'atokenvalue', 'client_id' => 'a client id', 'user_id' => 'a user id', 'expires' => 99999999900, 'scope' => 'basicUser withPermission anExtraScope']]]);
     $server = new \OAuth2\Server($storage, ['enforce_state' => true, 'allow_implicit' => false, 'access_lifetime' => 3600]);
     \Slim\Environment::mock(['CONTENT_TYPE' => 'application/json', 'PATH_INFO' => '/foo']);
     $slim = self::getSlimInstance();
     $authorization = new Authorization($server);
     $authorization->setApplication($slim);
     $slim->get('/foo', $authorization->withRequiredScope(['superUser', ['basicUser', 'withPermission']]), function () {
     });
     $env = \Slim\Environment::getInstance();
     $slim->request = new \Slim\Http\Request($env);
     $slim->request->headers->set('Authorization', 'Bearer atokenvalue');
     $slim->response = new \Slim\Http\Response();
     $slim->run();
     $this->assertSame(200, $slim->response->status());
     $this->assertSame(['access_token' => 'atokenvalue', 'client_id' => 'a client id', 'user_id' => 'a user id', 'expires' => 99999999900, 'scope' => 'basicUser withPermission anExtraScope'], $slim->token);
 }
开发者ID:salt-lick,项目名称:slim-oauth2-middleware,代码行数:26,代码来源:AuthorizationTest.php


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