Skip to content

Commit

Permalink
Merge branch 'webimpress-feature/authentication-0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Aug 23, 2018
2 parents 6dd093e + 8267ea4 commit 14e4a72
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -24,7 +24,7 @@
"psr/container": "^1.0",
"psr/http-message": "^1.0.1",
"psr/http-server-middleware": "^1.0",
"zendframework/zend-expressive-authentication": "^0.4.0"
"zendframework/zend-expressive-authentication": "^0.5"
},
"require-dev": {
"phpunit/phpunit": "^7.0.2",
Expand Down
25 changes: 7 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/AuthorizationMiddleware.php
Expand Up @@ -47,7 +47,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return ($this->responseFactory)()->withStatus(401);
}

foreach ($user->getUserRoles() as $role) {
foreach ($user->getRoles() as $role) {
if ($this->authorization->isGranted($role, $request)) {
return $handler->handle($request);
}
Expand Down
9 changes: 6 additions & 3 deletions test/AuthorizationMiddlewareTest.php
Expand Up @@ -15,15 +15,13 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Zend\Expressive\Authentication\DefaultUser;
use Zend\Expressive\Authentication\UserInterface;
use Zend\Expressive\Authentication\UserRepository\UserTrait;
use Zend\Expressive\Authorization\AuthorizationInterface;
use Zend\Expressive\Authorization\AuthorizationMiddleware;

class AuthorizationMiddlewareTest extends TestCase
{
use UserTrait;

/** @var AuthorizationInterface|ObjectProphecy */
private $authorization;

Expand Down Expand Up @@ -123,4 +121,9 @@ public function testProcessRoleGranted()

$this->assertSame($this->responsePrototype->reveal(), $response);
}

private function generateUser(string $identity, array $roles = []) : DefaultUser
{
return new DefaultUser($identity, $roles);
}
}

0 comments on commit 14e4a72

Please sign in to comment.