Skip to content

Commit 127569c

Browse files
Apply suggestions from code review
Co-authored-by: Lidia Zuin <102308961+lidiazuin@users.noreply.github.com>
1 parent 4c283fc commit 127569c

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

modules/ROOT/pages/security/authentication.adoc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33

44
The GraphQL Library offers the `@authentication` directive to configure authentication for certain operations and for different parts of your schema.
55

6-
[NOTE]
7-
Explicit authentication, configured with the `@authentication` directive, is only ever evaluated during Cypher translation time, and unauthenticated requests with queries requiring authentication never reach the database.
6+
[IMPORTANT]
7+
====
8+
Explicit authentication, configured with the `@authentication` directive, is only ever evaluated during Cypher translation time.
9+
Unauthenticated requests with queries requiring authentication never reach the database.
10+
====
811

912
== Operations
1013

@@ -19,7 +22,6 @@ Authentication can be configured to only be validated on certain operations:
1922
* `DELETE_RELATIONSHIP`
2023
* `SUBSCRIBE`
2124

22-
2325
For instance, to only require authentication for the update or deletion of a user:
2426

2527
[source, graphql, indent=0]
@@ -32,15 +34,15 @@ type User @authentication(operations: [UPDATE, DELETE]) {
3234
----
3335

3436
[NOTE]
35-
If there is no `operations` argument with a list of operations, the GraphQL Library treats the authentication configuration as if the full list of operations had been provided.
36-
37+
====
38+
In case there is no `operations` argument with a list of operations, the GraphQL Library treats the authentication configuration as if the full list of operations had been provided.
39+
====
3740

3841
== Scope
3942

40-
4143
=== Global authentication
4244

43-
Athentication can be applied to the entire schema.
45+
Authentication can be applied to the entire schema.
4446
This ensures authentication is checked for every matching request.
4547

4648
Extend the schema:

modules/ROOT/pages/security/authorization.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ type Post @authorization(filter: [
6767
----
6868

6969
[NOTE]
70-
If there is no `operations` argument with a list of operations, the GraphQL Library treats the authorization configuration as if the full list of operations had been provided.
70+
====
71+
In case there is no `operations` argument with a list of operations, the GraphQL Library treats the authorization configuration as if the full list of operations had been provided.
72+
====
7173

7274

7375
=== Validating
@@ -119,7 +121,9 @@ type Post @authorization(validate: [
119121
----
120122

121123
[NOTE]
122-
If there is no `operations` argument with a list of operations, the GraphQL Library treats the authorization configuration as if the full list of operations had been provided.
124+
====
125+
In case there is no `operations` argument with a list of operations, the GraphQL Library treats the authorization configuration as if the full list of operations had been provided.
126+
====
123127

124128

125129
== Authorization without authentication

modules/ROOT/pages/security/configuration.adoc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The Neo4j GraphQL Library uses JSON Web Token (JWT) authentication.
55
JWTs are tokens containing claims or statements about the user or client making the request.
66
These claims can include information such as the user's ID or roles.
77

8-
A JWT can be obtained from an authentication service and is then included in an API request.
8+
A JWT can be obtained from an authentication service and then be included in an API request.
99
The API verifies the JWT and returns the requested data if the JWT is valid.
1010

1111
== Instantiation
@@ -17,8 +17,9 @@ The Neo4j GraphQL Library can accept two types of JWTs:
1717

1818
=== Encoded JWTs
1919

20-
To use encoded JWTs, the library can be configured with a key to decode and verify the tokens.
21-
The following code block uses Apollo Server, extracts the `Authorization` header from the request and puts it in the appropriate context field:
20+
In order to use encoded JWTs, configure the library with a key to decode and verify the tokens.
21+
The following code block uses Apollo Server.
22+
It extracts the `Authorization` header from the request and puts it in the appropriate context field:
2223

2324
[source, typescript, indent=0]
2425
----
@@ -115,8 +116,9 @@ interface JwtPayload {
115116
----
116117

117118
[WARNING]
119+
====
118120
Do not pass in the header or the signature.
119-
121+
====
120122

121123
=== Decoded JWTs
122124

@@ -136,8 +138,7 @@ const { url } = await startStandaloneServer(server, {
136138
----
137139

138140
`customImplementation` is a placeholder for a function that provides a decoded JWT.
139-
Using `jwt` instead of `token` in the `context` informs the Neo4jGraphQL library that it doesn't need to decode it.
140-
141+
Using `jwt` instead of `token` in the `context` informs the Neo4j GraphQL Library that it doesn't need to decode it.
141142

142143
== Adding JWT claims
143144

@@ -157,12 +158,15 @@ type JWT @jwt {
157158
----
158159

159160
[NOTE]
160-
Note that the type name `JWT` is not required.
161+
====
162+
The type name `JWT` is not mandatory.
161163
You can use any name as long as it is decorated with the `@jwt` directive.
164+
====
162165

163166
=== The `@jwtClaim` directive
164167

165-
A `roles` claim is not necessarily located at the JWT payload root, but can instead be in a nested location, for example under `myApplication`:
168+
A `roles` claim is not necessarily located at the JWT payload root.
169+
It can instead be in a nested location, for example under `myApplication`:
166170

167171
[source, json, indent=0]
168172
----
@@ -195,7 +199,7 @@ Additionally, the nested location may contain `.` characters in the path, for ex
195199
}
196200
----
197201

198-
Escape these characters:
202+
These characters must be escaped:
199203

200204
[source, graphql, indent=0]
201205
----

modules/ROOT/pages/security/operations.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This page showcases a number of GraphQL queries and how you can trigger the evaluation of different authentication and authorization rules.
66

7-
Each relevant line has a comment such as `CREATE ON OBJECT Movie`, which means an authentication directive like the following is be evaluated:
7+
Each relevant line has a comment such as `CREATE ON OBJECT Movie`, which means an authentication directive like the following is evaluated:
88

99
[source, graphql, indent=0]
1010
----
@@ -14,8 +14,10 @@ type Movie @authentication(operations: [CREATE]) {
1414
}
1515
----
1616

17-
[NOTE]
17+
[IMPORTANT]
18+
====
1819
This also applies if the directive has no arguments because `operations` defaults to _all_ operations.
20+
====
1921

2022
The following examples apply to the `@authentication` directive, and also any rules within an `@authorization` directive.
2123

0 commit comments

Comments
 (0)