-
Notifications
You must be signed in to change notification settings - Fork 220
Add config option to disable introspection query #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Disable introspection | ||
===================== | ||
|
||
This bundle supports [webonyx/graphql-php validation rule to disable introspection queries](webonyx/graphql-php). | ||
|
||
Introspection is a mechanism for fetching schema structure. It is used by tools like GraphiQL for auto-completion, query validation, etc. | ||
|
||
It means that anybody can get a full description of your schema by sending a special query containing meta fields __type and __schema. | ||
|
||
If you are not planning to expose your API to the general public, it makes sense to disable this feature in production. By disabling, tools like GraphiQL won't work anymore. | ||
|
||
```yaml | ||
#app/config/config.yml | ||
overblog_graphql: | ||
security: | ||
disable_introspection: '%kernel.debug%' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. replace by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or just renaming the config entry There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, i think that is probably the best solution. I will change this today or tomorrow and I will add the necessary change to have the introspection enabled by default to avoid any BC issues. |
||
``` | ||
|
||
Introspection is enabled by default. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ Security | |
* [Fields public control](fields-public-control.md) | ||
* [Limiting query depth](limiting-query-depth.md) | ||
* [Query complexity analysis](query-complexity-analysis.md) | ||
* [Disable introspection](disable_introspection.md) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please also add this entry to main readme file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will do |
||
|
||
Next step [handling errors](../error-handling/index.md) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
imports: | ||
- { resource: ../config.yml } | ||
- { resource: ../connection/services.yml } | ||
|
||
overblog_graphql: | ||
security: | ||
disable_introspection: true | ||
definitions: | ||
class_namespace: "Overblog\\GraphQLBundle\\QueryComplexity\\__DEFINITIONS__" | ||
schema: | ||
query: Query | ||
mutation: ~ | ||
mappings: | ||
types: | ||
- | ||
type: yaml | ||
dir: "%kernel.root_dir%/config/queryComplexity/mapping" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Overblog\GraphQLBundle\Tests\Functional\Security; | ||
|
||
use Overblog\GraphQLBundle\Tests\Functional\TestCase; | ||
|
||
class DisableIntrospectionTest extends TestCase | ||
{ | ||
private $introspectionQuery = <<<'EOF' | ||
query { | ||
__schema { | ||
types { | ||
name | ||
description | ||
} | ||
} | ||
} | ||
EOF; | ||
|
||
public function testIntrospectionDisabled() | ||
{ | ||
$expected = [ | ||
'errors' => [ | ||
[ | ||
'message' => 'GraphQL introspection is not allowed, but the query contained __schema or __type', | ||
'category' => 'graphql', | ||
'locations' => [ | ||
[ | ||
'line' => 2, | ||
'column' => 3, | ||
], | ||
], | ||
], | ||
], | ||
]; | ||
|
||
$this->assertResponse($this->introspectionQuery, $expected, self::ANONYMOUS_USER, 'disableIntrospection'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix the url