Skip to content

Commit 4cd684e

Browse files
committed
review suggestions
1 parent c1c90c1 commit 4cd684e

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

modules/ROOT/pages/security/configuration.adoc

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The Neo4j GraphQL Library can accept two types of JWTs:
1717

1818
=== Encoded JWTs
1919

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

2323
[source, typescript, indent=0]
@@ -36,7 +36,7 @@ const { url } = await startStandaloneServer(server, {
3636

3737
Optionally, if a custom decoding mechanism is required, that same header can be decoded and the resulting JWT payload put into the `jwt` field of the context.
3838

39-
// ^ Can we show the above in a code listing?
39+
Alternatively, you can decode a token via a xref:#_jwks_endpoint[].
4040

4141
==== Symmetric secret
4242

@@ -74,8 +74,6 @@ new Neo4jGraphQL({
7474

7575
==== Passing in encoded JWTs
7676

77-
// What about decoded JWTs?
78-
7977
To pass in an encoded JWT, use the token field of the context.
8078
When using Apollo Server, extract the authorization header into the token property of the context:
8179

@@ -119,9 +117,27 @@ interface JwtPayload {
119117
[WARNING]
120118
Do not pass in the header or the signature.
121119

120+
122121
=== Decoded JWTs
123122

124-
// What could be added here?
123+
A decoded JWT is passed to the context in a similar way that an encoded JWT is.
124+
However, instead of using a token, it uses the `jwt` field:
125+
126+
[source, typescript, indent=0]
127+
----
128+
const jwt = customImplementation();
129+
130+
const { url } = await startStandaloneServer(server, {
131+
listen: { port: 4000 },
132+
context: async ({ req }) => ({
133+
jwt: jwt,
134+
}),
135+
});
136+
----
137+
138+
`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+
125141

126142
== Adding JWT claims
127143

0 commit comments

Comments
 (0)