【composer开发】身份管理简介

每个用户或者participant都有一个X509证书。
MSP很麻烦,但是composer简化了它的生成步骤。

business network card 包含颁发给用户的加密相关的证书以及composer链接档案(记录来了链接fabric机构里不同组件的urls)。

因此在以composer为基础构建的network application中,participant需要一个card和network application交互。

composer有角色:这些角色用于管理participants的权限。

角色

peer administrator是fabric建立时就有的一部分
network administrator是 network app建立时的一部分
其他participant其他participant是由network administrator建立或者是由一个有权限的participant建立的。

composer CLI tool

使用这个工具的用户必须有权限去管理identities。
在使用cli tool的时候,一定要提供合适的card。
使用命令

-c option

命令
composer participant add --help
composer identity --help

第一条命令用于添加participant到app中;
第二条命令用于执行围绕identities的多个操作(app中)。

命令一
cielo@cielo-ThinkPad-E550:~/cprogrames$ composer identity --help
composer identity <subcommand>

Composer identity command

Commands:
  composer identity bind [options]     Bind an existing identity to a participant in a participant registry
  composer identity issue [options]    Issue a new identity to a participant in a participant registry
  composer identity list [options]     List all identities in a business network
  composer identity request [options]  Request an identity's certificate and key
  composer identity revoke [options]   Revoke an identity that was issued or bound to a participant

Options:
  --help         Show help  [boolean]

bind用于链接现有的identity(或证书)和participant;
issue用于向participant发布新identity或card;
list列出现有的identity;
request得到存在的一个identity的card;
revoke是撤销一个app中的identity。

SDK、API

为business network application创建新的identity的步骤

Step1: 生成一个participant实例;

participant有三种生成的方式。
(1)playground或rest server
(2)composer CLI tool
(3)SDK或API

Step2: 为participant创建一个identity或者将一个identity与这个participant结合forBNA【有权限生成一个participant实例的用户执行此操作】

cielo@cielo-ThinkPad-E550:~/cprogrames$ composer identity issue --help
composer identity issue [options]

Issue a new identity to a participant in a participant registry

Options:
  --help               Show help  [boolean]
  -v, --version        Show version number  [boolean]
  --newUserId, -u      The user ID for the new identity  [string]
  --participantId, -a  The participant to issue the new identity to  [string] [required]
  --issuer, -x         If the new identity should be able to issue other new identities  [boolean]
  --option, -o         Options that are specific to connection. Multiple options are specified by repeating this option  [string]
  --optionsFile, -O    A file containing options that are specific to connection  [string]
  --card, -c           Name of the network card to use for issuing  [string]
  --file, -f           The card file name for the new identity  [string]

这一步会生成一个card,这个card和identity绑定,是这个participant的card。

Step3: import 在第二步生成的card

演示

playground

生成一个participant后,点击右上角的 ID registry进去。
在这里插入图片描述
在ID Registry页面进行给card的操作。
在这里插入图片描述
如果选了这个allow,他就可以生成新的Participant了。

在这里插入图片描述
生成之后wallet会出现这人的card。

ERROR

但我又出现了不明错误,说是这个card没有读权限。那它能干嘛,在哪授权???找了一圈没找到授权的地方啊。懵。
在这里插入图片描述

cli tool

Step1

composer participant add -d {json格式的participant数据} -c【card name】

cielo@cielo-ThinkPad-E550:~/cprogrames$ composer participant add -d '{"$class":"org.acme.airline.participant.ACMENetworkAdmin","participantKey":"alice","contact":{"$class":"org.acme.airline.participant.Contact","fName":"Alice","lname":"Wang","email":"alice.wang@acmeairline.com"}}' -c admin@airlinev8
Participant was added to participant registry.

Command succeeded

Step2
composer identity issue -u

composer identity issue -u alice -a org.acme.airline.participant.ACMENetworkAdmin#alice -c admin@airlinev8 -x

-u 这个identity的名字
-a 这个identity会和谁(participant)结合
-c cardname
-x 设置这个用户是否可以新建其他用户。

Step3: import 在第二步生成的card

cielo@cielo-ThinkPad-E550:~/cprogrames/airlinev1/dist$ composer card import -f alice@airlinev8.card

Successfully imported business network card
        Card file: alice@airlinev8.card
        Card name: alice@airlinev8

Command succeeded

cielo@cielo-ThinkPad-E550:~/cprogrames/airlinev1/dist$ composer card list
The following Business Network Cards are available:

Connection Profile: hlfv1
┌─────────────────┬───────────┬──────────────────┐
│ Card Name       │ UserId    │ Business Network │
├─────────────────┼───────────┼──────────────────┤
│ admin@airlinev8 │ admin     │ airlinev8        │
├─────────────────┼───────────┼──────────────────┤
│ admin@test-bna  │ admin     │ test-bna         │
├─────────────────┼───────────┼──────────────────┤
│ alice@airlinev8 │ alice     │ airlinev8        │
├─────────────────┼───────────┼──────────────────┤
│ PeerAdmin@hlfv1 │ PeerAdmin │                  │
└─────────────────┴───────────┴──────────────────┘


Issue composer card list --card <Card Name> to get details a specific card

Command succeeded
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值