Hyperledger,将Google OAUTH2.0与REST服务器配合使用 [英] Hyperledger, Using Google OAUTH2.0 with a REST server

查看:112
本文介绍了Hyperledger,将Google OAUTH2.0与REST服务器配合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我部署了网络以从REST客户端查询并启动REST实例.我想使用Google Oauth满足身份验证需求,但是碰巧出现了身份验证错误.

网络位于localhost:3000上,看起来不错;但是,当我导入名片并试用"/system/historian时,会得到以下响应正文:

错误":{ "statusCode":500, "name":错误", "message":尝试登录并获取用户上下文时出错.错误:尝试注册用户或加载频道配置时出错.错误:注册失败,错误为[[{{code":20,"message":授权失败"}] ]", "stack":错误:尝试登录并获取用户上下文时出错.错误:尝试注册用户或加载频道配置时出错.错误:注册失败,错误为[[{{code":20,"message":授权失败" }]] \ n在client.getUserContext.then.then.catch(/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js: 395:34)\ n at process._tickDomainCallback(internal/process/next_tick.js:228:7)"

预期的行为是显示一组交易

我检查了钱包,以为卡可能有问题,但似乎没有问题.代码是预期的200,这是响应正文:

[ { "name":"liner1", 默认":false }, { 名称":"liner1 @ iot-perishable-network-advanced", 默认":true } ]

解决方案

如果您想将卡导入到电子钱包中,则可以使用Google Oauth配置.

这似乎是您导入的卡的问题.颁发身份(并创建卡)后,将创建一次性机密.首次使用卡时,将机密交换为证书/密钥,并且一次性机密无效.

我猜您已经为一个已经使用过的用户导入了一个.card文件,所以现在机密无效.如果我是对的,则需要将卡从其工作位置导出到包含证书/密钥的新.card文件中,然后将该新.card文件导入REST服务器钱包中.也许您正在寻找命令composer card export.

作曲家中提供了有关卡的更多信息.知识Wiki .

I deployed the network to query from the REST client and launched the REST instance. I wanted to use Google Oauth for the authentication needs but there happens to be an authentication error.

The network is on the localhost:3000 and looks fine; however, when I import a business card and "try it out" the /system/historian I get this response body:

"error": { "statusCode": 500, "name": "Error", "message": "Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Enrollment failed with errors [[{"code":20,"message":"Authorization failure"}]]", "stack": "Error: Error trying login and get user Context. Error: Error trying to enroll user or load channel configuration. Error: Enrollment failed with errors [[{"code":20,"message":"Authorization failure"}]]\n at client.getUserContext.then.then.catch (/home/composer/.npm-global/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:395:34)\n at \n at process._tickDomainCallback (internal/process/next_tick.js:228:7)"

The expected behaviour was to get a set of transactions showed up

I checked the wallet, thinking I might have a problem with the card but there seems to be no problem. The code is 200 which is expected, and here is the response body:

[ { "name": "liner1", "default": false }, { "name": "liner1@iot-perishable-network-advanced", "default": true } ]

解决方案

If you have got as far as importing a card to a Wallet, then your Google Oauth config is fine.

This looks like a problem with the card you have imported. When the Identity is Issued (and the Card is created) a one-time secret is created. When the card is used for the first time the secret is exchanged for Certificates/Keys and the the one-time secret is invalidated.

I'm guessing that you have imported a .card file for a user which has already been used, so now the secret is invalid. If I'm right, you need to export the card from the place where it is working to a new .card file that contains the certificates/keys, and import that new .card file into the REST server wallet. Maybe the command composer card export is what you are looking for.

There is more information on cards in the Composer Knowledge Wiki.

这篇关于Hyperledger,将Google OAUTH2.0与REST服务器配合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆