From 0fab314b13f4f0fef815e947d6c02930cea0baa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Tue, 4 Dec 2018 01:20:50 +0100 Subject: [PATCH 1/3] Wording: Use `reset-db` for the file name, too FYI: @Mastercuber --- package.json | 2 +- src/seed/{unseed-db.js => reset-db.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/seed/{unseed-db.js => reset-db.js} (100%) diff --git a/package.json b/package.json index bdc2c0c80..a5fe9e159 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "start:debug": "./node_modules/.bin/nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js", "db:no-auth-server": "cross-env GRAPHQL_URI=http://localhost:4001 PERMISSIONS=disabled GRAPHQL_PORT=4001 yarn run start", "db:script:seed": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/seed-db.js", - "db:script:reset": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/unseed-db.js", + "db:script:reset": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/reset-db.js", "db:seed": "concurrently --kill-others --success first -n no-auth-server,seed \"yarn run db:no-auth-server\" \"yarn run db:script:seed\"", "db:reset": "concurrently --kill-others --success first -n no-auth-server,reset \"yarn run db:no-auth-server\" \"yarn run db:script:reset\"" }, diff --git a/src/seed/unseed-db.js b/src/seed/reset-db.js similarity index 100% rename from src/seed/unseed-db.js rename to src/seed/reset-db.js From d355974b6e2aed27d7a495c4454b3aacf9c9c766 Mon Sep 17 00:00:00 2001 From: Armin Kunkel Date: Tue, 4 Dec 2018 03:52:33 +0100 Subject: [PATCH 2/3] Add troubleshoot to kubernetes README --- kubernetes/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kubernetes/README.md b/kubernetes/README.md index 81c6c4f88..5192f9a19 100644 --- a/kubernetes/README.md +++ b/kubernetes/README.md @@ -6,14 +6,15 @@ First of all start minikube on your machine: ```sh minikube start ``` -[troubleshoot] If you get an error message along th lines of 'The vboxdrv kernel module is not loaded.' - then you have the same issue i had. to solve this you need to install the propper linux kernel host modules package. Here an example for Manjaro: +**[troubleshoot]** If you get an error message along th lines of 'The vboxdrv kernel module is not loaded.' - then you have the same issue i had. to solve this you need to install the propper linux kernel host modules package. Here an example for Manjaro: https://forum.manjaro.org/t/installing-virtualbox-kernel-modules/6999 +**[troubleshoot]** When you can not start minikube, try also to remove the cluster with `minikube delete` and start again with `minikube start`. Sometimes this fix startup problems of the cluster. You can always get an overview and see what's going on with your minikube: ```sh minikube dashboard ``` -[troubleshoot] now again you might run into trouble with an error like 'kubectl could not be found on your path.' In this case run the following command: +**[troubleshoot]** now again you might run into trouble with an error like 'kubectl could not be found on your path.' In this case run the following command: ```sh curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo cp kubectl /usr/local/bin/ && rm kubectl ``` From 43b5d8eeb0b76b4d2b1917ba47b79ae2b2e71626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Tue, 4 Dec 2018 21:41:19 +0100 Subject: [PATCH 3/3] Follow @appinteractives review See: https://github.com/Human-Connection/Nitro-Backend/pull/40#pullrequestreview-180898363 https://github.com/Human-Connection/Nitro-Backend/pull/40#pullrequestreview-180950115 --- package.json | 12 +++++++----- src/middleware/permissionsMiddleware.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index a5fe9e159..6986d1d93 100644 --- a/package.json +++ b/package.json @@ -3,16 +3,18 @@ "version": "0.0.1", "description": "GraphQL Backend for Human Connection", "main": "src/index.js", + "config": { + "no_auth": "cross-env GRAPHQL_URI=http://localhost:4001 GRAPHQL_PORT=4001 PERMISSIONS=disabled" + }, "scripts": { "eslint": "eslint src --config .eslintrc.js", "test": "echo \"Error: no test specified\" && exit 0", "start": "./node_modules/.bin/nodemon --exec babel-node src/index.js", "start:debug": "./node_modules/.bin/nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js", - "db:no-auth-server": "cross-env GRAPHQL_URI=http://localhost:4001 PERMISSIONS=disabled GRAPHQL_PORT=4001 yarn run start", - "db:script:seed": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/seed-db.js", - "db:script:reset": "wait-on tcp:4001 && cross-env GRAPHQL_URI=http://localhost:4001 ./node_modules/.bin/babel-node src/seed/reset-db.js", - "db:seed": "concurrently --kill-others --success first -n no-auth-server,seed \"yarn run db:no-auth-server\" \"yarn run db:script:seed\"", - "db:reset": "concurrently --kill-others --success first -n no-auth-server,reset \"yarn run db:no-auth-server\" \"yarn run db:script:reset\"" + "db:script:seed": "wait-on tcp:4001 && $npm_package_config_no_auth ./node_modules/.bin/babel-node src/seed/seed-db.js", + "db:script:reset": "wait-on tcp:4001 && $npm_package_config_no_auth ./node_modules/.bin/babel-node src/seed/reset-db.js", + "db:seed": "concurrently --kill-others --success first -n no-auth-server,seed '$npm_package_config_no_auth yarn run start' 'yarn run db:script:seed'", + "db:reset": "concurrently --kill-others --success first -n no-auth-server,reset '$npm_package_config_no_auth yarn run start' 'yarn run db:script:reset'" }, "author": "Human Connection gGmbH", "license": "MIT", diff --git a/src/middleware/permissionsMiddleware.js b/src/middleware/permissionsMiddleware.js index e95fd49d8..5b0cb87d2 100644 --- a/src/middleware/permissionsMiddleware.js +++ b/src/middleware/permissionsMiddleware.js @@ -1,5 +1,19 @@ import { rule, shield, allow } from 'graphql-shield' +/* + * TODO: implement + * See: https://github.com/Human-Connection/Nitro-Backend/pull/40#pullrequestreview-180898363 +const isAuthenticated = rule()(async (parent, args, ctx, info) => { + return ctx.user !== null +}) +const isAdmin = rule()(async (parent, args, ctx, info) => { + return ctx.user.role === 'ADMIN' +}) +const isModerator = rule()(async (parent, args, ctx, info) => { + return ctx.user.role === 'MODERATOR' +}) +*/ + const isOwner = rule()(async (parent, args, ctx, info) => { return ctx.user.id === parent.id })