From 4f9d534708312634fffe9596f2a5b1350a257cfd Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Mon, 13 Jun 2016 17:07:15 +0200 Subject: [PATCH] Removed silent try catching on access resolver --- README.md | 6 +++--- Resolver/AccessResolver.php | 7 +------ Tests/Functional/Security/AccessTest.php | 21 ------------------- .../config/access/mapping/access.types.yml | 1 - 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8be822b97..717128de3 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ overblog_graphql_endpoint: resource: "@OverblogGraphQLBundle/Resources/config/routing/graphql.yml" ``` -**c)** Enable GraphiQL in dev mode (required twig) +**d)** Enable GraphiQL in dev mode (required twig) ```yaml # in app/config/routing_dev.yml @@ -865,8 +865,8 @@ Expression | Description | Scope ---------- | ----------- | -------- **container** | DI container | global **request** | Refers to the current request. | Request -**token** | Refers to the token which is currently in the security token storage. | Token -**user** | Refers to the user which is currently in the security token storage. | Valid Token +**token** | Refers to the token which is currently in the security token storage. Token can be null. | Token +**user** | Refers to the user which is currently in the security token storage. User can be null. | Valid Token **object** | Refers to the value of the field for which access is being requested. For array `object` will be each item of the array. For Relay connection `object` will be the node of each connection edges. | only available for `config.fields.*.access` with query operation or mutation payload type. **value** | Resolver value | only available in resolve context **args** | Resolver args array | only available in resolve context diff --git a/Resolver/AccessResolver.php b/Resolver/AccessResolver.php index 46cf1ead7..ceb4586f2 100644 --- a/Resolver/AccessResolver.php +++ b/Resolver/AccessResolver.php @@ -70,12 +70,7 @@ function (Edge $edge) use ($accessChecker, $resolveArgs) { private function hasAccess(callable $accessChecker, $object, array $resolveArgs = []) { $resolveArgs[] = $object; - - try { - $access = (bool) call_user_func_array($accessChecker, $resolveArgs); - } catch (\Exception $e) { - $access = false; - } + $access = (bool) call_user_func_array($accessChecker, $resolveArgs); return $access; } diff --git a/Tests/Functional/Security/AccessTest.php b/Tests/Functional/Security/AccessTest.php index 2a58d7781..4185b00c3 100644 --- a/Tests/Functional/Security/AccessTest.php +++ b/Tests/Functional/Security/AccessTest.php @@ -156,27 +156,6 @@ public function testUserAccessToUserFriends() $this->assertResponse($this->userFriendsQuery, $expected, static::USER_ADMIN); } - public function testUserAccessToUserIsEnabledWithExpressionLanguageEvaluationFailed() - { - $expected = [ - 'data' => [ - 'user' => [ - 'isEnabled' => null, - ], - ], - 'extensions' => [ - 'warnings' => [ - [ - 'message' => 'Access denied to this field.', - 'locations' => [['line' => 1, 'column' => 24]], - ], - ], - ], - ]; - - $this->assertResponse($this->userIsEnabledQuery, $expected, static::USER_ADMIN); - } - public function testMutationAllowedUser() { $result = 123; diff --git a/Tests/Functional/app/config/access/mapping/access.types.yml b/Tests/Functional/app/config/access/mapping/access.types.yml index 8beae5eeb..623ebfc08 100644 --- a/Tests/Functional/app/config/access/mapping/access.types.yml +++ b/Tests/Functional/app/config/access/mapping/access.types.yml @@ -35,7 +35,6 @@ User: resolve: ['ROLE_USER'] isEnabled: type: Boolean - access: "@=service('fake').fake()" resolve: true friends: access: "@=object === 1"