Skip to content

Commit 351759a

Browse files
committed
review suggestions
1 parent 174b276 commit 351759a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

modules/ROOT/content-nav.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
1111
* *Reference*
1212
* xref:security/index.adoc[]
13-
** xref:security/securing-a-graphql-api.adoc[]
1413
** xref:security/configuration.adoc[]
1514
** xref:security/authentication.adoc[]
1615
** xref:security/authorization.adoc[]
@@ -58,6 +57,7 @@
5857
5958
* xref:driver-configuration.adoc[]
6059
* xref:graphql-modeling.adoc[]
60+
* xref:security/securing-a-graphql-api.adoc[]
6161
6262
* *Products*
6363

modules/ROOT/pages/security/securing-a-graphql-api.adoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ The xref:directives/schema-configuration/field-configuration.adoc#_selectable[`@
6464

6565
=== Authentication
6666

67-
The xref:security/authentication.adoc[`@authentication` directive] can be applied globally, only to certain fields or only to certain types, and only for certain operations.
67+
You can apply the xref:security/authentication.adoc[`@authentication` directive] either globally, only to certain fields or only to certain types, and only for certain operations.
6868

69-
Add admin authorization for operations on customers, orders, products, categories and suppliers:
69+
Add authentication as an admin to operations on customers, orders, products, categories and suppliers:
7070

7171
* `DELETE` for customers,
7272
* `UPDATE` and `DELETE` for orders,
@@ -139,7 +139,9 @@ JWT are represented by encoded JSON data.
139139
These data can have arbitrary fields - which ones they should contain depends on the application preferences.
140140

141141
For instance, if the server side is trying to parse the `roles` field that was introduced in xref:#_authentication[], then the JWT should contain that.
142-
With `@jwtClaim`, you can specify a path to a customer ID in a nested location.
142+
Specify the types of JWT data with `@jwt`.
143+
Then you can specify a path to a customer ID in a nested location with `@jwtClaim`.
144+
143145
For example:
144146

145147
[source, graphql, indent=0]
@@ -167,7 +169,7 @@ type Customer
167169
@node
168170
@authentication(operations: [DELETE], jwt: { roles: { includes: "admin" } })
169171
@authorization(
170-
filter: [ <1>
172+
filter: [
171173
{ operations: [READ], where: { node: { customerID: { eq: "$jwt.customerID" } } } }
172174
{ where: { jwt: { roles: { includes: "admin" } } } }
173175
]
@@ -181,7 +183,7 @@ type Order
181183
@node
182184
@authentication(operations: [UPDATE, DELETE], jwt: { roles: { includes: "admin" } })
183185
@authorization(
184-
filter: [ <2>
186+
filter: [
185187
{ where: { node: { customer: { all: { customerID: { eq: "$jwt.customerID" } } } } } }
186188
{ where: { jwt: { roles: { includes: "admin" } } } }
187189
]
@@ -207,7 +209,7 @@ type Customer
207209
) {
208210
contactName: String!
209211
adminNotes: [String!]! @authorization(
210-
validate: [ <1>
212+
validate: [
211213
{ where: { jwt: { roles: { includes: "admin" } } } }
212214
]
213215
)
@@ -323,13 +325,12 @@ type ordersProperties @relationshipProperties {
323325
Besides authentication and authorization considerations, there are a couple of worthwhile best practices to increase your API's security.
324326

325327

326-
=== Avoid introspection and data field suggestions
328+
=== Introspection and data field suggestions
327329

328330
While the xref:getting-started/graphql-aura.adoc[Getting started page for GraphQL and Aura Console] advocates to both **Enable introspection** as well as **Enable field suggestions**, this is not recommended when considering security.
329331

330332
Both potentially expose information that can be used to gain insight on specifics of your GraphQL schema and execute targeted malicious operations.
331-
Be sure to deactivate both in a customer-facing real-life scenario.
332-
333+
We recommend you to deactivate both in a customer-facing real-life scenario unless you have a good reason to use them.
333334

334335

335336
=== Limit query depth
@@ -482,5 +483,4 @@ You can set a timeout via the GraphQL Library driver, see xref:driver-configurat
482483

483484
Neo4j has a link:https://neo4j.com/docs/operations-manual/current/authentication-authorization/manage-privileges/[Role-based access control] mechanism that can be leveraged to increase security even further.
484485

485-
486-
486+
For more security-related topics in GraphQL, refer to the link:https://www.graphql.org/learn/security/[GraphQL Security] page.

0 commit comments

Comments
 (0)