0xHexE / keycloak-hasura-connector

Connect hasura with the keycloak. Authentication for hasura
https://httpsomkar.github.io/keycloak-hasura-connector/
MIT License
105 stars 22 forks source link

Error: AnonymousRole: must be of type String #61

Closed SameerChorge94 closed 4 years ago

SameerChorge94 commented 4 years ago

Error from images,
hasura docker yaml file according to above example hasura graphql engine image was old so i updated the image versions Docker-compose.yaml file

version: '3.6'
services:
  postgres:
    image: postgres:12
    restart: always
    volumes:
      - db_data:/var/lib/postgresql/data
  graphql-engine:
    image: hasura/graphql-engine:v1.3.0
    ports:
      - "8080:8080"
    depends_on:
      - "postgres"
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
      HASURA_GRAPHQL_DEV_MODE: "true"
      HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
      HASURA_GRAPHQL_ADMIN_SECRET: supersecret
      HASURA_GRAPHQL_AUTH_HOOK: http://auth:3000
  auth:
    image: httpsomkar/keycloak-hasura-connector:latest
    environment:
      KEYCLOAK_CLIENT_ID: hasura-keycloak-connector # Keycloak backend client id from the keycloak setup.
      KEYCLOAK_SERVER_URL: http://192.168.0.113:8081/auth # Keycloak url in term of http://keycloak.COMPANY.com/auth
      KEYCLOAK_REALM: Customer-Portal # Default to master if any new create change to it
      KEYCLOAK_SECRET: 87fdcdd0-9ad8-4f18-86d9-950e2fb9c0d6 # Secret copied from the backend client -> Credentials
      KEYCLOAK_DEBUG: "true" # If testing enable mention this file

volumes:
  db_data:

Error from docker container logs:

hasura-connector@0.0.1-beta start /usr/src/app node src/main.js

/usr/src/app/node_modules/convict/lib/convict.js:686 throw new Error(output); ^

Error: AnonymousRole: must be of type String at Object.validate (/usr/src/app/node_modules/convict/lib/convict.js:686:17) at Object. (/usr/src/app/src/config.js:80:8) at Module._compile (internal/modules/cjs/loader.js:1176:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10) at Module.load (internal/modules/cjs/loader.js:1040:32) at Function.Module._load (internal/modules/cjs/loader.js:929:14) at Module.require (internal/modules/cjs/loader.js:1080:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/usr/src/app/src/main.js:3:16) at Module._compile (internal/modules/cjs/loader.js:1176:30) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! hasura-connector@0.0.1-beta start: node src/main.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the hasura-connector@0.0.1-beta start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2020-08-11T16_58_11_866Z-debug.log PS D:\Keycloak\Docker\hasura>

0xHexE commented 4 years ago

Try to add this env variable ANONYMOUS_ROLE to auth.

auth:
  environment: guest

Something like this