Skip to content

Latest commit

 

History

History
147 lines (111 loc) · 4.07 KB

File metadata and controls

147 lines (111 loc) · 4.07 KB

NOTES

TODO: cleanup NOTES and KeyCloak stuff

NOTE: project started from nestjs-oficial-repo/sample/12-graphql-schema-first

Add nest-keycloak-connect

$ npm install nest-keycloak-connect --save
peer @nestjs/common@"^7.0.3" from nest-keycloak-connect@1.6.1

$ git clone https://github.com/ferrerojosh/nest-keycloak-connect.git

get project version from starter/package.json, ex 8.0.2

  "dependencies": {
    "@nestjs/common": "8.0.2",

and and replace 7.0.3 in nest-keycloak-connect/package.json

  "peerDependencies": {
    "@nestjs/common": "^7.0.3",
  },
  "devDependencies": {
    "@nestjs/common": "^7.0.3",
    "@nestjs/core": "^7.0.3",
  }
}
$ rm nest-keycloak-connect/package-lock.json
$ rm starter/package-lock.json
$ cd starter
$ npm i ../nest-keycloak-connect/
$ npm i
  "dependencies": {
    "nest-keycloak-connect": "file:../nest-keycloak-connect",
  },

donw now we have dependency installed

Fix all package problems updating all nest-keycloak-connect to new versions

update all packages to new versions nest-keycloak-connect/package.json

$ cd nest-keycloak-connect
$ npm i
$ cd starter
$ npm i

now it build

Fix module dependecies first

import {
  KeycloakConnectModule,
  ResourceGuard,
  RoleGuard,
  AuthGuard,
  PolicyEnforcementMode,
  TokenValidation
} from 'nest-keycloak-connect';

Cannot find module 'nest-keycloak-connect' or its corresponding type declarations.ts(2307)

$ cd nest-keycloak-connect
$ npm run build

done now we have folder nest-keycloak-connect/dist

the trick is installing from dist folder with

$ cd starter
$ npm i ../nest-keycloak-connect/dist

register the module in app.module.ts

get code from example at nest-keycloak-connect/example/src/app.module.ts

create starter/keycloak.json

{
  "realm": "Demo-Realm",
  "auth-server-url": "https://auth.koakh.com/auth",
  "ssl-required": "external",
  "resource": "nest-api",
  "verify-token-audience": true,
  "credentials": {
    "secret": "f2912fae-a536-4685-a477-b59582bee3cb"
  },
  "confidential-port": 0,
  "policy-enforcer": {}
}
$ npm run start:debug
[Nest] 9313  - 07/12/2021, 8:19:20 PM     LOG [NestFactory] Starting Nest application...
[Nest] 9313  - 07/12/2021, 8:19:20 PM    WARN [KeycloakConnectModule] Token validation is disabled, please only do this on development/special use-cases.
[Nest] 9313  - 07/12/2021, 8:19:20 PM   ERROR [ExceptionHandler] Nest can\'t resolve dependencies of the ResourceGuard (KEYCLOAK_INSTANCE, KEYCLOAK_CONNECT_OPTIONS, KEYCLOAK_LOGGER, ?). Please make sure that the argument Reflector at index [3] is available in the AppModule context.

Potential solutions:

Leave keycloak for now

Debug Neo4j GraphQL Library

  • Troubleshooting - Neo4j GraphQL Library

  • @neo4j/graphql:* - Logs all

  • @neo4j/graphql:auth - Logs the status of authorization header and token extraction, and decoding of JWT

  • @neo4j/graphql:graphql - Logs the GraphQL query and variables

  • @neo4j/graphql:execute - Logs the Cypher and Cypher paramaters before execution, and summary of execution

ex add DEBUG=@neo4j/graphql:auth to debug script