javascript - @neo4j/graphql:auth JWT 未配置
问题描述
我正在尝试从一个简单的 dockerized nodejs 应用程序访问 dockerized neo4j。
以下是我的docker-compose
配置:
version: '2.1'
services:
neo4j:
image: neo4j:latest
container_name: ltimdb_neo4j
ports:
- "7474:7474"
- "7687:7687"
volumes:
- $HOME/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/import:/var/lib/neo4j/import
- $HOME/plugins:/plugins
environment:
- NEO4J_apoc_export_file_enabled=true
- NEO4J_apoc_import_file_enabled=true
- NEO4J_apoc_import_file_use__neo4j__config=true
- NEO4JLABS_PLUGINS=\[\"apoc\"\]
- NEO4J_AUTH=neo4j/ltimdb
networks:
- default
restart: always
graphql:
build: ./ltimdb-graphql-api-server
container_name: ltimdb_graphql
depends_on:
- neo4j
environment:
- NEO4J_URI=bolt://neo4j:7687
- NEO4J_USER=neo4j
- NEO4J_PASSWORD=ltimdb
ports:
- "4000:4000"
networks:
- default
restart: always
如您所见,我已经在启动 neo4j 并将适当的凭据传递给 nodejs 应用程序容器时更改了密码。但我仍然无法通过此设置访问数据库。相同的代码在没有 dockerization 的情况下可以工作,但之后无法工作。
我在我的应用程序中访问 neo4j,如下所示:
const driver = neo4j.driver(
process.env.NEO4J_URI,
neo4j.auth.basic(process.env.NEO4J_USER, process.env.NEO4J_PASSWORD)
);
我已经登录控制台NEO4J_URI
,NEO4J_USER
并NEO4J_PASSWORD
从应用程序中查看他们是否正确地访问了应用程序并且它的记录正常。
我在控制台上收到以下错误:
graphql_1 | 2021-06-16T08:43:22.736Z @neo4j/graphql:auth JWT not configured
graphql_1 | 2021-06-16T08:43:22.743Z @neo4j/graphql:execute About to execute Cypher:
graphql_1 | Cypher:
graphql_1 | MATCH (this:Movie)
graphql_1 | RETURN this { .title } as this
graphql_1 | Params:
graphql_1 | {}
neo4j_1 | 2021-06-16 08:43:22.950+0000 WARN The client is unauthorized due to authentication failure.
graphql_1 | 2021-06-16T08:43:23.003Z @neo4j/graphql:execute Neo4jError: The client is unauthorized due to authentication failure.
graphql_1 |
graphql_1 | at captureStacktrace (/usr/src/app/node_modules/neo4j-driver-core/lib/result.js:239:17)
graphql_1 | at new Result (/usr/src/app/node_modules/neo4j-driver-core/lib/result.js:59:23)
graphql_1 | at newCompletedResult (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:372:12)
graphql_1 | at Object.run (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:226:20)
graphql_1 | at Transaction.run (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:98:34)
graphql_1 | at /usr/src/app/node_modules/@neo4j/graphql/dist/utils/execute.js:63:108
graphql_1 | at TransactionExecutor._safeExecuteTransactionWork (/usr/src/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:92:26)
graphql_1 | at TransactionExecutor._executeTransactionInsidePromise (/usr/src/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:83:34)
graphql_1 | at /usr/src/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:40:19
graphql_1 | at new Promise (<anonymous>) {
graphql_1 | constructor: [Function: Neo4jError],
graphql_1 | code: 'Neo.ClientError.Security.Unauthorized'
另外,我想指出我没有@auth
在我的 graphql 类型定义中使用注释,我猜这可能需要 JWT 身份验证。
请建议。TIA。
解决方案
推荐阅读
- c++ - 【MacOSX 10.15.1】使用odb生成数据库,致命错误:wchar.h: No such file or directory #include
- flutter - 在小部件测试期间检查颜色?
- android - awsmobileclient 中的无密码自定义身份验证流程
- ruby-on-rails - 在多台服务器上运行的 Rails 应用程序中,如何确保 rake 任务只运行一次?
- javascript - dyld:库未加载:/usr/local/opt/icu4c/lib/libicui18n.63.dylib 引用自:/usr/local/opt/node@8/bin/node
- c# - 如何在 c# 中设置两个显示和隐藏表单的键绑定?
- python - 在 Django 模板中显示文本文件的内容
- javascript - 是否可以在 window.prompt 弹出窗口上显示移动数字键盘?
- flutter - 如何在颤动中将日期时间转换为持续时间?
- angular - ngOnChanges 不会触发