From 33521e4544fcb568b193142e141251a3f4501a95 Mon Sep 17 00:00:00 2001 From: Ralph Depping Date: Thu, 17 Nov 2022 21:31:47 +0000 Subject: [PATCH 1/5] Add opa binary download step --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 67d5816..a1acdd3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,14 @@ A matching tutorial is expected to be available soon. ## Setup +Download the [latest opa binary](https://www.openpolicyagent.org/docs/latest/#running-opa) for your platform. + +For arm64 based macos: +```bash +curl -L -o /usr/local/bin/opa https://github.com/open-policy-agent/opa/releases/download/v0.46.1/opa_darwin_arm64_static +chmod 755 /usr/local/bin/opa +``` + The GraphQL application, the bundle server, and OPA all run in docker-containers. For convenience, we included a docker-compose file, so you'll want [docker-compose](https://docs.docker.com/compose/install/) installed. From aedc505b5cce947dc5c9d0f6522ac307b6f529a9 Mon Sep 17 00:00:00 2001 From: Ralph Depping Date: Thu, 17 Nov 2022 21:41:34 +0000 Subject: [PATCH 2/5] Add reference to tutorial --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1acdd3..335ca83 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This directory helps provide fine-grained, policy-based control over who can run which GraphQL API queries. -A matching tutorial is expected to be available soon. +A [matching tutorial is available](https://www.openpolicyagent.org/docs/latest/graphql-api-authorization/). ## Contents From 6df1d29058f36a9ee9becb8999003493db074bcc Mon Sep 17 00:00:00 2001 From: Ralph Depping Date: Thu, 17 Nov 2022 21:44:04 +0000 Subject: [PATCH 3/5] Add a verification example --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 335ca83..7099278 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,17 @@ To instead use the example with JSON Web Tokens, use the following make commands make # build the containers with docker make up-token # start the containers with docker-compose ``` + +To verify that the system is working as expected define a helper function and use it to submit a graphql query as follows + +```bash +❯ gql-query() { + curl --user "$1" -H "Content-Type: application/json" "$2" --data-ascii "$3" +} + +❯ gql-query alice:password "localhost:5000/" '{"query":"query { employeeByID(id: \"alice\") { salary }}"}' +``` +the response back should be +``` +{"data":{"employeeByID":{"salary":3664}}} +``` From 7dfbf6ea1d13ab98d128f7eba7e1f739ab163657 Mon Sep 17 00:00:00 2001 From: Ralph Depping Date: Fri, 18 Nov 2022 08:49:08 +0000 Subject: [PATCH 4/5] Minor readme updates --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7099278..0ce6e67 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A [matching tutorial is available](https://www.openpolicyagent.org/docs/latest/g Download the [latest opa binary](https://www.openpolicyagent.org/docs/latest/#running-opa) for your platform. -For arm64 based macos: +For exmaple - for an arm64 based macos: ```bash curl -L -o /usr/local/bin/opa https://github.com/open-policy-agent/opa/releases/download/v0.46.1/opa_darwin_arm64_static chmod 755 /usr/local/bin/opa @@ -47,7 +47,7 @@ make # build the containers with docker make up-token # start the containers with docker-compose ``` -To verify that the system is working as expected define a helper function and use it to submit a graphql query as follows +To verify that the application is working as expected, you can define a helper function and use it to submit a graphql query as follows: ```bash ❯ gql-query() { @@ -56,7 +56,7 @@ To verify that the system is working as expected define a helper function and us ❯ gql-query alice:password "localhost:5000/" '{"query":"query { employeeByID(id: \"alice\") { salary }}"}' ``` -the response back should be +the response back should look like the following ``` {"data":{"employeeByID":{"salary":3664}}} ``` From fe0e5b4dbbd40acf7154e16b84018a1cb5fac9c3 Mon Sep 17 00:00:00 2001 From: Ralph Depping Date: Fri, 18 Nov 2022 09:01:12 +0000 Subject: [PATCH 5/5] Remove unhelpful shell prompt and fix up example opa download --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0ce6e67..687ad83 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A [matching tutorial is available](https://www.openpolicyagent.org/docs/latest/g Download the [latest opa binary](https://www.openpolicyagent.org/docs/latest/#running-opa) for your platform. -For exmaple - for an arm64 based macos: +For example - for an arm64 based macos and v0.46.1 is the latest release: ```bash curl -L -o /usr/local/bin/opa https://github.com/open-policy-agent/opa/releases/download/v0.46.1/opa_darwin_arm64_static chmod 755 /usr/local/bin/opa @@ -50,11 +50,11 @@ make up-token # start the containers with docker-compose To verify that the application is working as expected, you can define a helper function and use it to submit a graphql query as follows: ```bash -❯ gql-query() { +gql-query() { curl --user "$1" -H "Content-Type: application/json" "$2" --data-ascii "$3" } -❯ gql-query alice:password "localhost:5000/" '{"query":"query { employeeByID(id: \"alice\") { salary }}"}' +gql-query alice:password "localhost:5000/" '{"query":"query { employeeByID(id: \"alice\") { salary }}"}' ``` the response back should look like the following ```