You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* check access to resolve any field (include root level fields, child field, ast fields).
125
+
Bundle provides two ways to guard your application: using black/white operation list or using security voter.
126
+
127
+
#### Black/white list
128
+
Used to guard some root operations. To enable it you need to write following in your config.yml file:
129
+
```yaml
130
+
graph_ql:
131
+
132
+
#...
133
+
134
+
security:
135
+
black_list: ['hello'] # or white_list: ['hello']
136
+
137
+
```
138
+
#### Using security voter:
139
+
Used to guard any field resolve and support two types of guards: root operation and any other field resolving (including internal fields, scalar type fields, root operations). To guard root operation with your specified logic you need to enable it in configuration and use `SecurityManagerInterface::RESOLVE_ROOT_OPERATION_ATTRIBUTE` attribute. The same things need to do to enable field guard, but in this case use `SecurityManagerInterface::RESOLVE_FIELD_ATTRIBUTE` attribute.
140
+
[Official documentation](http://symfony.com/doc/current/security/voters.html) about voters.
128
141
129
142
> Note: Enabling field security lead to a significant reduction in performance
130
143
131
-
To enable security you need to write following in your config.yml file:
144
+
Config example:
132
145
```yaml
133
146
graph_ql:
134
147
security:
135
148
field_resolve: true # for any field security
136
149
root_operation_resolve: true # for root level security
137
150
```
138
-
Then to create standard security voter for that ([official documentation](http://symfony.com/doc/current/security/voters.html)), as in example below:
151
+
152
+
Voter example (add in to your `services.yml` file with tag `security.voter`):
139
153
```php
140
154
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
141
155
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@@ -176,11 +190,10 @@ class GraphQLVoter extends Voter
176
190
}
177
191
}
178
192
```
179
-
Now GraphQL executor will check access for every field/operation, based on configuration.
180
193
181
194
182
195
## GraphiQL extension:
183
-
To run [graphiql extension](https://github.com/graphql/graphiql) just try to access to `http://your_domain/explorer`
196
+
To run [graphiql extension](https://github.com/graphql/graphiql) just try to access to `http://your_domain/graphql/explorer`
184
197
185
198
## Documentation
186
199
All detailed documentation is available on the main GraphQL repository – http://github.com/youshido/graphql/.
0 commit comments