Has permissions - #10
Open
alexanderdomin wants to merge 5 commits into
Open
alexanderdomin wants to merge 5 commits into
alexanderdomin wants to merge 5 commits into
Conversation
The `@hasPermissions` directive, enforces the resolution of a field/type to be guarded by a list of permissions. For more information on how to use it, refer to: https://github.com/profusion/apollo-validation-directives#haspermissions As we are using a mocked environment, we need to apply the SchemaDirectiveVisitor on top of the schema with the mocked resolvers - since Apollo replace the resolvers with mocked ones. That's why we are not using `mock: true` on ApolloServer creation but rather the explicit function `addMockFunctionsToSchema`. Change-Id: I30eb09b60866068a6693c1f0c919c8898f06b47e
If we receive a JWT token on the request, the server is going to verify and decode it to get the incoming list of permissions by the client. This permissions are attached to the server context so that they can be validated by the `@hasPermissions` directive. To decode the token, an cryptographic algorithm key must be given. For now, this key is being read by one of the two places defined in the .env file: - PUBLIC_KEY_FILE: used for RSA asymmetric mechanisms, it is a file path that contains the contents of the key (loaded dynamically by the server) - SECRET_KEY: used for HMAC symmetric mechanism, it is the value of the key that can be generated using `uuidgen` for example. Change-Id: Ib56ee3a0a299de46647f8efbdd2fd705cf0f75ab
The .env.example is a reference to .env configuration files used on this project. This files are used to store environments configuration that should be changed in different deploys. For now, we are using the .env to store the keys used to decrypt the JWT token and set the default port for GraphQL Server. See README.md for more information on how to setup. Change-Id: I34e116a93ffabf9d8feb77cd99b934db8419b771
Change-Id: I870feb9680a4d21c27e4ce8944485ce6ebb0297e
On the scalar fields of the schema, create `@hasPermissions` directive with permissions that needs to be checked when resolving the field. The schema permissions will be checked against the permissions from the JWT token sent on the request - if not present, GraphQL will throw an error. Change-Id: I1d43aff81f6cfdc5c5873d3514c3f658d505fba9
slawr
reviewed
Jan 19, 2021
|
We merged the PRs in the order they were given, so #7 was merged first. But it also implemented some simple resolvers. |
Open
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adopting the schema and adding permission validation to the GraphQL server implementation.