-
Notifications
You must be signed in to change notification settings - Fork 15
Updates for the security section #168
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b57242c
reordered overview page links to match navigation
rsill-neo4j b34ea6a
Merge branch '5.x' into updates-for-security-section
rsill-neo4j 5ddefe4
some changes to the configuration page
rsill-neo4j 381f006
some adjustments, some answered questions
rsill-neo4j c1c90c1
added an admonition, made it clearer that @jwtClaim is used alongside…
rsill-neo4j 4cd684e
review suggestions
rsill-neo4j 9658364
changes to the authentication page
rsill-neo4j c6fdc97
some more polish on various pages
rsill-neo4j 4c283fc
rephrased index page a bit
rsill-neo4j 127569c
Apply suggestions from code review
rsill-neo4j c51c458
restored index page style
rsill-neo4j 12648b2
superfluous word
rsill-neo4j 4a408be
Apply suggestions from code review
rsill-neo4j File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,64 @@ | ||
| = Authentication | ||
| :description: This page describes how to set up authentication features in the Neo4j GraphQL Library. | ||
|
|
||
| Explicit authentication, configured using the `@authentication` directive, is only ever evaluated | ||
| during Cypher translation time, and unauthenticated requests with queries requiring authentication | ||
| will never reach the database. | ||
| The GraphQL Library offers the `@authentication` directive to configure authentication for certain operations and for different parts of your schema. | ||
|
|
||
| == Configuration | ||
| [IMPORTANT] | ||
| ==== | ||
| Explicit authentication, configured with the `@authentication` directive, is only ever evaluated during Cypher translation time. | ||
| Unauthenticated requests with queries requiring authentication never reach the database. | ||
| ==== | ||
|
|
||
| Authentication can be configured for an entire type, for example, the type `User`: | ||
| == Operations | ||
|
|
||
| Authentication can be configured to only be validated on certain operations: | ||
|
|
||
| * `CREATE` | ||
| * `READ` | ||
| * `AGGREGATE` | ||
| * `UPDATE` | ||
| * `DELETE` | ||
| * `CREATE_RELATIONSHIP` | ||
| * `DELETE_RELATIONSHIP` | ||
| * `SUBSCRIBE` | ||
|
|
||
| For instance, to only require authentication for the update or deletion of a user: | ||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
| type User @authentication(operations: [UPDATE, DELETE]) { | ||
| id: ID! | ||
| name: String! | ||
| password: String! | ||
| } | ||
| ---- | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| 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. | ||
| ==== | ||
|
|
||
rsill-neo4j marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| == Scope | ||
|
|
||
| === Global authentication | ||
|
|
||
| Authentication can be applied to the entire schema. | ||
| This ensures authentication is checked for every matching request. | ||
|
|
||
| Extend the schema: | ||
rsill-neo4j marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
| extend schema @authentication | ||
| ---- | ||
|
|
||
| The `operations` and `jwt` arguments can also be used when the directive is applied to a schema extension. | ||
|
|
||
| // ^ should we add links or provide examples? | ||
|
||
|
|
||
| === Authentication for types | ||
|
|
||
| Authentication can be configured for an entire type: | ||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
|
|
@@ -18,7 +69,7 @@ type User @authentication { | |
| } | ||
| ---- | ||
|
|
||
| Authentication will thus be validated when any of the following operations are _attempted_: | ||
| With this configuration, authentication is validated when any of the following operations are _attempted_: | ||
|
|
||
| * *Create*: `createUsers` mutation, `create`, or `connectOrCreate` nested operation via a related type. | ||
| * *Read*: `users`, `usersConnection`, `usersAggregate` query, or access via related type. | ||
|
|
@@ -28,7 +79,10 @@ Authentication will thus be validated when any of the following operations are _ | |
| * *Delete relationship*: `disconnect` nested operation via a related type. | ||
| * *Subscribe*: all subscription operations related to type `User`. | ||
|
|
||
| Additionally, the directive can be configured on a per-field basis, for example: | ||
|
|
||
| === Authentication for fields | ||
|
|
||
| Authentication can be configured on a per-field basis, for example: | ||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
|
|
@@ -39,37 +93,13 @@ type User { | |
| } | ||
| ---- | ||
|
|
||
| This will only be evaluated in the following circumstances: | ||
| This is only evaluated under the following circumstances: | ||
|
|
||
| * The `password` field is set on either `create` or `update`. | ||
| * The `password` field is present in a selection set. | ||
|
|
||
| === Operations | ||
|
|
||
| Authentication can be configured to only be validated on certain operations: | ||
|
|
||
| * `CREATE` | ||
| * `READ` | ||
| * `AGGREGATE` | ||
| * `UPDATE` | ||
| * `DELETE` | ||
| * `CREATE_RELATIONSHIP` | ||
| * `DELETE_RELATIONSHIP` | ||
| * `SUBSCRIBE` | ||
|
|
||
|
|
||
| For instance, to only require authentication for the update or deletion of a user: | ||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
| type User @authentication(operations: [UPDATE, DELETE]) { | ||
| id: ID! | ||
| name: String! | ||
| password: String! | ||
| } | ||
| ---- | ||
|
|
||
| === Additional verification | ||
| == Additional verification | ||
|
|
||
| Additional checks against JWT claims can be performed together with authentication. | ||
| For instance, if it was a requirement that only users with the `admin` role can delete users: | ||
|
|
@@ -81,18 +111,4 @@ type User @authentication(operations: [DELETE], jwt: { roles_INCLUDES: "admin" } | |
| name: String! | ||
| password: String! | ||
| } | ||
| ---- | ||
|
|
||
| == Global authentication | ||
|
|
||
| Additionally, authentication can be applied to the entire schema. | ||
| This ensures authentication is checked for every matching request. | ||
|
|
||
| This is done via extending the schema: | ||
|
|
||
| [source, graphql, indent=0] | ||
| ---- | ||
| extend schema @authentication | ||
| ---- | ||
|
|
||
| The `operations` and `jwt` arguments can also be used when the directive is applied to a schema extension. | ||
| ---- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.