diff --git a/.circleci/config.yml b/.circleci/config.yml index a3ca58d0dba..7cf15c62efb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,7 @@ # anchor refs to be used elsewhere refs: constants: - # TODO upload to hasura docker hub: - # - &server_builder_image hasura/graphql-engine-server-builder:2020-01-14 - - &server_builder_image jberryman/graphql-engine-server-builder-8.10:2020-04-29 + - &server_builder_image hasura/graphql-engine-server-builder:2020-08-26 skip_job_on_ciignore: &skip_job_on_ciignore run: name: checking if job should be terminated or not @@ -22,7 +20,7 @@ refs: if [ -z "$CIRCLE_PR_NUMBER" ]; then echo "Not a PR build, continuing test" && exit 0 fi - echo "Compare refs: ${CIRCLE_COMPARE_URL##http*/}" + echo "Compare refs: ${CIRCLE_COMPARE_URL##http*/}" if git diff --quiet "${CIRCLE_COMPARE_URL##http*/}" -- server; then echo "No server changes present, skipping test" circleci-agent step halt @@ -165,10 +163,10 @@ jobs: - checkout - restore_cache: keys: - - cabal-store-v2-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/cabal.project.freeze" }} - - cabal-store-v2-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}- - - cabal-store-v2-{{ checksum "server/cabal.project" }}- - - cabal-store-v2- + - cabal-store-v3-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/cabal.project.freeze" }} + - cabal-store-v3-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}- + - cabal-store-v3-{{ checksum "server/cabal.project" }}- + - cabal-store-v3- - run: name: Install latest postgresql client tools command: | @@ -187,7 +185,7 @@ jobs: make enable_coverage=true ci-build fi - save_cache: - key: cabal-store-v2-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/cabal.project.freeze" }} + key: cabal-store-v3-{{ checksum "server/cabal.project" }}-{{ checksum "server/graphql-engine.cabal" }}-{{ checksum "server/cabal.project.freeze" }} paths: - ~/.cabal/packages - ~/.cabal/store @@ -416,7 +414,7 @@ jobs: root: /build paths: - _cli_output - + test_and_build_cli_migrations: docker: - image: hasura/graphql-engine-cli-migrations-builder:20200415 diff --git a/.circleci/server-builder.dockerfile b/.circleci/server-builder.dockerfile index 9d41df603be..429298c9aff 100644 --- a/.circleci/server-builder.dockerfile +++ b/.circleci/server-builder.dockerfile @@ -1,8 +1,6 @@ # Don't update this without updating the # packager imager of graphql-engine -FROM phadej/ghc:8.10.1-stretch -# TODO https://github.com/haskell/docker-haskell/issues/17 -#FROM haskell:8.10.1 +FROM haskell:8.10.2-stretch ARG docker_ver="17.09.0-ce" ARG postgres_ver="12" @@ -14,7 +12,10 @@ RUN apt-get -y update \ && echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ && curl -s https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ && apt-get -y update \ - && apt-get install -y g++ gcc libc6-dev libpq-dev libffi-dev libgmp-dev make xz-utils zlib1g-dev git gnupg upx netcat python3 python3-pip postgresql-client-${postgres_ver} postgresql-client-common \ + && apt-get install -y \ + g++ gcc git gnupg libc6-dev libffi-dev libgmp-dev libkrb5-dev \ + libpq-dev libssl-dev make netcat postgresql-client-${postgres_ver} \ + postgresql-client-common python3 python3-pip upx xz-utils zlib1g-dev \ && curl -sL https://deb.nodesource.com/setup_${node_ver} | bash - \ && apt-get install -y nodejs \ && curl -Lo /tmp/docker-${docker_ver}.tgz https://download.docker.com/linux/static/stable/x86_64/docker-${docker_ver}.tgz \ diff --git a/.circleci/test-server.sh b/.circleci/test-server.sh index e097cf051a6..65f9bc0c221 100755 --- a/.circleci/test-server.sh +++ b/.circleci/test-server.sh @@ -383,6 +383,51 @@ kill_hge_servers unset HASURA_GRAPHQL_JWT_SECRET +# test JWT with Claims map +echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH ADMIN SECRET AND JWT (with claims_map and values are json path) #####################################>\n" +TEST_TYPE="jwt-claims-map-with-json-path-values" + +export HASURA_GRAPHQL_JWT_SECRET="$(jq -n --arg key "$(cat $OUTPUT_FOLDER/ssl/jwt_public.key)" '{ type: "RS512", key: $key , claims_map: {"x-hasura-user-id": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].user.id"}, "x-hasura-allowed-roles": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].role.allowed"}, "x-hasura-default-role": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].role.default"}}}')" + +run_hge_with_args serve +wait_for_port 8080 + +pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --hge-jwt-key-file="$OUTPUT_FOLDER/ssl/jwt_private.key" --hge-jwt-conf="$HASURA_GRAPHQL_JWT_SECRET" test_jwt_claims_map.py::TestJWTClaimsMapBasic + +kill_hge_servers + +unset HASURA_GRAPHQL_JWT_SECRET + +echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH ADMIN SECRET AND JWT (with claims_map and values are json path with default values set) #####################################>\n" +TEST_TYPE="jwt-claims-map-with-json-path-values-with-default-values" + +export HASURA_GRAPHQL_JWT_SECRET="$(jq -n --arg key "$(cat $OUTPUT_FOLDER/ssl/jwt_public.key)" '{ type: "RS512", key: $key , claims_map: {"x-hasura-user-id": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].user.id", "default":"1"}, "x-hasura-allowed-roles": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].role.allowed", "default":["user","editor"]}, "x-hasura-default-role": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].role.default","default":"user"}}}')" + +run_hge_with_args serve +wait_for_port 8080 + +pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --hge-jwt-key-file="$OUTPUT_FOLDER/ssl/jwt_private.key" --hge-jwt-conf="$HASURA_GRAPHQL_JWT_SECRET" test_jwt_claims_map.py::TestJWTClaimsMapBasic + +kill_hge_servers + +unset HASURA_GRAPHQL_JWT_SECRET + + +echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH ADMIN SECRET AND JWT (with claims_map and values are literal values) #####################################>\n" +TEST_TYPE="jwt-claims-map-with-literal-values" + +export HASURA_GRAPHQL_JWT_SECRET="$(jq -n --arg key "$(cat $OUTPUT_FOLDER/ssl/jwt_public.key)" '{ type: "RS512", key: $key , claims_map: {"x-hasura-user-id": {"path":"$.['"'"'https://myapp.com/jwt/claims'"'"'].user.id"}, "x-hasura-allowed-roles": ["user","editor"], "x-hasura-default-role": "user","x-hasura-custom-header":"custom-value"}}')" + +run_hge_with_args serve +wait_for_port 8080 + +pytest -n 1 -vv --hge-urls "$HGE_URL" --pg-urls "$HASURA_GRAPHQL_DATABASE_URL" --hge-key="$HASURA_GRAPHQL_ADMIN_SECRET" --hge-jwt-key-file="$OUTPUT_FOLDER/ssl/jwt_private.key" --hge-jwt-conf="$HASURA_GRAPHQL_JWT_SECRET" test_jwt_claims_map.py::TestJWTClaimsMapWithStaticHasuraClaimsMapValues + +kill_hge_servers + +unset HASURA_GRAPHQL_JWT_SECRET + + # test with CORS modes echo -e "\n$(time_elapsed): <########## TEST GRAPHQL-ENGINE WITH CORS DOMAINS ########>\n" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ff6da16b5e..acad5c5a876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,41 @@ ## Next release +### Server - Support for mapping session variables to default JWT claims + +Some auth providers do not let users add custom claims in JWT. In such cases, the server can take a JWT configuration option called `claims_map` to specify a mapping of Hasura session variables to values in existing claims via JSONPath or literal values. + +Example:- + +Consider the following JWT claim: + +``` + { + "sub": "1234567890", + "name": "John Doe", + "admin": true, + "iat": 1516239022, + "user": { + "id": "ujdh739kd", + "appRoles": ["user", "editor"] + } + } +``` + +The corresponding JWT config can be: + +``` + { + "type":"RS512", + "key": "", + "claims_map": { + "x-hasura-allowed-roles": {"path":"$.user.appRoles"}, + "x-hasura-default-role": {"path":"$.user.appRoles[0]","default":"user"}, + "x-hasura-user-id": {"path":"$.user.id"} + } + } +``` + ### Breaking changes This release contains the [PDV refactor (#4111)](https://github.com/hasura/graphql-engine/pull/4111), a significant rewrite of the internals of the server, which did include some breaking changes: @@ -11,7 +46,6 @@ This release contains the [PDV refactor (#4111)](https://github.com/hasura/graph - if a query selects table `bar` through table `foo` via a relationship, the required permissions headers will be the union of the required headers of table `foo` and table `bar` (we used to only check the headers of the root table); - if an insert does not have an `on_conflict` clause, it will not require the update permissions headers. - ### Bug fixes and improvements (Add entries here in the order of: server, console, cli, docs, others) @@ -19,6 +53,7 @@ This release contains the [PDV refactor (#4111)](https://github.com/hasura/graph - server: some mutations that cannot be performed will no longer be in the schema (for instance, `delete_by_pk` mutations won't be shown to users that do not have select permissions on all primary keys) (#4111) - server: miscellaneous description changes (#4111) - server: treat the absence of `backend_only` configuration and `backend_only: false` equally (closing #5059) (#4111) +- server: allow remote relationships joining `type` column with `[type]` input argument as spec allows this coercion (fixes #5133) - console: allow user to cascade Postgres dependencies when dropping Postgres objects (close #5109) (#5248) - console: mark inconsistent remote schemas in the UI (close #5093) (#5181) - cli: add missing global flags for seeds command (#5565) diff --git a/community/sample-apps/svelte-apollo/README.md b/community/sample-apps/svelte-apollo/README.md index fbca0671667..86d09dd0a72 100644 --- a/community/sample-apps/svelte-apollo/README.md +++ b/community/sample-apps/svelte-apollo/README.md @@ -1,22 +1,19 @@ # svelte-graphql-app -A sample [Svelte 3](https://svelte.dev) app to demonstrate usage of GraphQL Queries, Mutations and Subscriptions with [svelte-apollo](https://github.com/timhall/svelte-apollo), Hasura GraphQL engine and Postgres as database. Forked from the standard svelte [template](https://github.com/sveltejs/template) +A sample [Svelte 3](https://svelte.dev) app to demonstrate usage of GraphQL Queries, Mutations and Subscriptions with [svelte-apollo](https://github.com/timhall/svelte-apollo), Hasura Cloud and Postgres as database. Forked from the standard svelte [template](https://github.com/sveltejs/template) [![Edit svelte-graphql](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/hasura/graphql-engine/tree/master/community/sample-apps/svelte-apollo?fontsize=14) -## Deploy Hasura +## Create new Hasura Cloud project -- Deploy Postgres and GraphQL Engine on Heroku: - - [![Deploy to - heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/hasura/graphql-engine-heroku) +- Create new Hasura Cloud project with the `Try a free database with Heroku` option. - Please checkout our [docs](https://hasura.io/docs/1.0/graphql/manual/deployment/index.html) for other deployment methods + Please check out our [docs](https://hasura.io/docs/cloud/1.0/manual/getting-started/index.html) for the detailed steps. -- Get the Heroku app URL (say `my-app.herokuapp.com`) +- Get the app URL (something like `https://.hasura.app`) - Create `author` table: - - Open Hasura console: visit https://my-app.herokuapp.com on a browser + + Open your Hasura Cloud project's console: visit `https://.hasura.app` on a browser Navigate to `Data` section in the top nav bar and create a table as follows: ![Create author table](../gatsby-postgres-graphql/assets/add_table.jpg) @@ -51,7 +48,7 @@ Install the dependencies... npm install ``` -- Open `src/apollo.js` and configure Hasura's GraphQL Endpoint as follows: +- Open `src/apollo.js` and configure Hasura's GraphQL Endpoint as follows: ```javascript @@ -72,7 +69,7 @@ npm install }); ``` -Replace the `uri` argument with your Hasura GraphQL Endpoint for both `wsLink` and `httpLink` +Replace the `uri` argument with your Hasura GraphQL Endpoint (something like `https://.hasura.app/v1/graphql`) for both `wsLink` and `httpLink` Start [Rollup](https://rollupjs.org): @@ -99,4 +96,3 @@ now ``` This will deploy the app on Now 2.0 Platform and you have the Svetle app running live :) - diff --git a/console/src/components/Services/Data/Schema/Schema.js b/console/src/components/Services/Data/Schema/Schema.js index a309ace261f..4aa992c7e2c 100644 --- a/console/src/components/Services/Data/Schema/Schema.js +++ b/console/src/components/Services/Data/Schema/Schema.js @@ -692,7 +692,7 @@ class Schema extends Component { className={styles.add_mar_top} key={'non-trackable-custom-functions'} > - +
{getNonTrackableFuncList()}
diff --git a/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js b/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js index e01d34bc8f7..c1ae4e82738 100644 --- a/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js +++ b/console/src/components/Services/Data/TableRelationships/RelationshipEditor.js @@ -112,11 +112,11 @@ class RelationshipEditor extends React.Component {
{getEditBtn()} {relName} +
-

{getRelDef(relConfig)}

diff --git a/docs/404.rst b/docs/404.rst index 809d02210dc..90afa47b1bc 100644 --- a/docs/404.rst +++ b/docs/404.rst @@ -1,5 +1,7 @@ .. title:: 404 - Page Not Found +:orphan: + 404 - Page Not Found --------------------- diff --git a/docs/_static/scripts/hdocs.js b/docs/_static/scripts/hdocs.js index 63ebf4343c0..0b58f80ecdd 100644 --- a/docs/_static/scripts/hdocs.js +++ b/docs/_static/scripts/hdocs.js @@ -14,8 +14,8 @@ window.hdocs = (function () { docsearch({ appId: 'WCBB1VVLRC', - apiKey: '298d448cd9d7ed93fbab395658da19e8', - indexName: 'graphql-docs-prod', + apiKey: HDOCS_ALGOLIA_API_KEY, + indexName: HDOCS_ALGOLIA_INDEX, inputSelector: '#search_element', transformData: hdocs.transformSearchData, debug: false diff --git a/docs/_static/styles/landing.css b/docs/_static/styles/landing.css index 258dec72de6..80f2ad096ef 100644 --- a/docs/_static/styles/landing.css +++ b/docs/_static/styles/landing.css @@ -15,13 +15,11 @@ } .body_content { - font-family: 'Gudea'; font-size: 15px; color: #333; } .small_content { - font-family: 'Gudea'; font-size: 14px; color: #333; } @@ -101,6 +99,10 @@ padding-bottom: 0; } +.description { + margin-bottom: 20px; +} + .text_left { text-align: left; } diff --git a/docs/_static/styles/main.css b/docs/_static/styles/main.css index 83fff027cdd..5a8e745fdac 100644 --- a/docs/_static/styles/main.css +++ b/docs/_static/styles/main.css @@ -640,6 +640,10 @@ article ol ol { margin: 15px; } +.sphinxsidebarwrapper > ul:not(.current) { + display: none; +} + #sidebar { background-color: #001934; width: 24% !important; diff --git a/docs/_theme/djangodocs/layout.html b/docs/_theme/djangodocs/layout.html index bd69ec9b91b..c9ce88388b3 100644 --- a/docs/_theme/djangodocs/layout.html +++ b/docs/_theme/djangodocs/layout.html @@ -4,6 +4,16 @@ {% set is_landing_page = true %} {%- endif %} +{%- if pagename.startswith('graphql/core') %} + {% set is_core = true %} + {% set ALGOLIA_INDEX = 'graphql-docs-prod' %} + {% set ALGOLIA_API_KEY = '298d448cd9d7ed93fbab395658da19e8' %} +{%- elif pagename.startswith('graphql/cloud') %} + {% set is_cloud = true %} + {% set ALGOLIA_INDEX = 'cloud-docs-prod' %} + {% set ALGOLIA_API_KEY = 'cf84f05a225bedb72ce472dada63d29f' %} +{%- endif %} + {% set css_files = css_files + ['_static/graphiql/graphiql.css', '_static/styles/main.css'] %} {%- if is_landing_page %} @@ -105,7 +115,7 @@
  • - + @@ -162,7 +172,7 @@
  • - + @@ -187,12 +197,12 @@ Close
    - + Hasura Core - + Hasura Cloud @@ -283,7 +293,7 @@