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
Configures the JWT authentication and authorization filters to include an additional JWT claim which is either nested or using special characters not supported by GraphQL.
:description: This page describes how to set up authentication features in the Neo4j GraphQL Library.
3
3
4
-
Explicit authentication, configured using the `@authentication` directive, is only ever evaluated
5
-
during Cypher translation time, and unauthenticated requests with queries requiring authentication
6
-
will never reach the database.
4
+
The GraphQL Library offers the `@authentication` directive to configure authentication for certain operations and for different parts of your schema.
7
5
8
-
== Configuration
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
+
====
9
11
10
-
Authentication can be configured for an entire type, for example, the type `User`:
12
+
== Operations
13
+
14
+
Authentication can be configured to only be validated on certain operations:
15
+
16
+
* `CREATE`
17
+
* `READ`
18
+
* `AGGREGATE`
19
+
* `UPDATE`
20
+
* `DELETE`
21
+
* `CREATE_RELATIONSHIP`
22
+
* `DELETE_RELATIONSHIP`
23
+
* `SUBSCRIBE`
24
+
25
+
For instance, to only require authentication for the update or deletion of a user:
26
+
27
+
[source, graphql, indent=0]
28
+
----
29
+
type User @authentication(operations: [UPDATE, DELETE]) {
30
+
id: ID!
31
+
name: String!
32
+
password: String!
33
+
}
34
+
----
35
+
36
+
[NOTE]
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
+
====
40
+
41
+
== Scope
42
+
43
+
=== Global authentication
44
+
45
+
Authentication can be applied to the entire schema.
46
+
This ensures authentication is checked for every matching request.
47
+
48
+
Extend the schema:
49
+
50
+
[source, graphql, indent=0]
51
+
----
52
+
extend schema @authentication
53
+
----
54
+
55
+
The `operations` and `jwt` arguments can also be used when the directive is applied to a schema extension, for example:
Copy file name to clipboardExpand all lines: modules/ROOT/pages/security/authorization.adoc
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,11 @@ type Post @authorization(filter: [
66
66
}
67
67
----
68
68
69
+
[NOTE]
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
+
====
73
+
69
74
70
75
=== Validating
71
76
@@ -115,6 +120,11 @@ type Post @authorization(validate: [
115
120
}
116
121
----
117
122
123
+
[NOTE]
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.
0 commit comments