Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BE-830 Add examples for fabric CA enabled network #210

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 46 additions & 10 deletions README-CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ This document will describe about the detail of each configuration:
* `expiresIn`: expressed in seconds or a string describing a time span [zeit/ms](https://github.com/zeit/ms).
Eg: `60`, `"2 days"`, `"10h"`, `"7d"`. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default (`"120"` is equal to `"120ms"`).

* Modify the connection profile (e.g. `app/platform/fabric/connection-profile/first-network.json`) to configure authorization of login user.
* Modify the connection profile (e.g. `app/platform/fabric/connection-profile/test-network.json`) to configure authorization of login user.

```json
"client": {
Expand Down Expand Up @@ -87,7 +87,7 @@ First you need to login using admin credential to get a JSON Web token.
--header 'Content-Type: application/json' --data-raw '{
"user": "exploreradmin",
"password": "exploreradminpw",
"network": "first-network"
"network": "test-network"
}' | jq .

{
Expand Down Expand Up @@ -135,15 +135,15 @@ First you need to login using admin credential to get a JSON Web token.
{
"username": "exploreradmin",
"email": null,
"networkName": "first-network",
"networkName": "test-network",
"firstName": null,
"lastName": null,
"roles": "admin"
},
{
"username": "newuser",
"email": null,
"networkName": "first-network",
"networkName": "test-network",
"firstName": null,
"lastName": null,
"roles": "user"
Expand Down Expand Up @@ -174,7 +174,7 @@ $ curl -s --location --request POST 'localhost:8080/api/unregister' \

## Enable TLS

* If your fabric network enables TLS, then set `true` to `client.tlsEnable` in the connection profile (e.g. `app/platform/fabric/connection-profile/first-network.json`).
* If your fabric network enables TLS, then set `true` to `client.tlsEnable` in the connection profile (e.g. `app/platform/fabric/connection-profile/test-network.json`).
And you also need to specify peer URL with `grpcs://`. If your fabrice network disables TLS, use `grpc://` instead.

```json
Expand All @@ -194,18 +194,18 @@ $ curl -s --location --request POST 'localhost:8080/api/unregister' \
```json
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json"
"test-network": {
"name": "Test Network",
"profile": "./connection-profile/test-network.json"
}
},
"license": "Apache-2.0"
}
```
* `first-network` is the name of your connection profile, and can be changed to any name.
* `test-network` is the name of your connection profile, and can be changed to any name.
* `name` is a name you want to give to your fabric network, you can change only value of the key "name".
* `profile` is the location of your connection profile, you can change only value of the key "profile"
* Change `fabric-path` to your fabric network disk path in the `first-network.json` file
* Change `fabric-path` to your fabric network disk path in the `test-network.json` file
* Provide the full disk path to the adminPrivateKey config option, it ussually ends with "_sk"\
e.g.
```json
Expand Down Expand Up @@ -256,6 +256,42 @@ $ curl -s --location --request POST 'localhost:8080/api/unregister' \
},
```

* Refer to the following sample connection files:
* `examples/net1/connection-profile/test-network-ca.json` (for using Docker)
* To use this profile, modify `docker-compose.yaml` as below:
```diff
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 9478ca1..ea6ae74 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -46,7 +46,7 @@ services:
- LOG_CONSOLE_STDOUT=true
- DISCOVERY_AS_LOCALHOST=false
volumes:
- - ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
+ - ./examples/net1/config-ca.json:/opt/explorer/app/platform/fabric/config.json
- ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- /fabric-path/fabric-samples/test-network/organizations:/tmp/crypto
- walletstore:/opt/explorer/wallet
```
* `app/platform/fabric/connection-profile/test-network-ca.json` (for using source tree)
* To use this profile, modify `app/platform/fabric/config.json` as below:
```diff
diff --git a/app/platform/fabric/config.json b/app/platform/fabric/config.json
index f99d37b..9825060 100644
--- a/app/platform/fabric/config.json
+++ b/app/platform/fabric/config.json
@@ -2,7 +2,7 @@
"network-configs": {
"test-network": {
"name": "Test Network",
- "profile": "./connection-profile/test-network.json"
+ "profile": "./connection-profile/test-network-ca.json"
}
},
"license": "Apache-2.0"
```

### Disable using Fabric CA

* You need to specify the following keys:
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ In this guide, we assume that you've already started test network by following [
* Copy the following files from repository

- [docker-compose.yaml](https://github.com/hyperledger/blockchain-explorer/blob/master/docker-compose.yaml)
- [examples/net1/connection-profile/first-network.json](https://github.com/hyperledger/blockchain-explorer/blob/master/examples/net1/connection-profile/first-network.json)
- [examples/net1/connection-profile/test-network.json](https://github.com/hyperledger/blockchain-explorer/blob/master/examples/net1/connection-profile/test-network.json)
- [examples/net1/config.json](https://github.com/hyperledger/blockchain-explorer/blob/master/examples/net1/config.json)


```
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/config.json
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/connection-profile/first-network.json -P connection-profile
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/examples/net1/connection-profile/test-network.json -P connection-profile
$ wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/docker-compose.yaml
```

Expand All @@ -78,7 +78,7 @@ In this guide, we assume that you've already started test network by following [
```
docker-compose.yaml
config.json
connection-profile/first-network.json
connection-profile/test-network.json
organizations/ordererOrganizations/
organizations/peerOrganizations/
```
Expand Down Expand Up @@ -120,7 +120,7 @@ In this guide, we assume that you've already started test network by following [
- DISCOVERY_AS_LOCALHOST=false
```

* Edit path to admin certificate and secret key in the connection profile (first-network.json). You need to specify with the absolute path on Explorer container.
* Edit path to admin certificate and secret key in the connection profile (test-network.json). You need to specify with the absolute path on Explorer container.

```json
"organizations": {
Expand Down Expand Up @@ -213,24 +213,24 @@ $ cd blockchain-explorer/app
```json
{
"network-configs": {
"first-network": {
"name": "firstnetwork",
"profile": "./connection-profile/first-network.json",
"test-network": {
"name": "Test Network",
"profile": "./connection-profile/test-network.json",
"enableAuthentication": false
}
},
"license": "Apache-2.0"
}
```

* `first-network` is the name of your connection profile, and can be changed to any name
* `test-network` is the name of your connection profile, and can be changed to any name
* `name` is a name you want to give to your fabric network, you can change only value of the key `name`
* `profile` is the location of your connection profile, you can change only value of the key `profile`

* Modify connection profile in the JSON file `app/platform/fabric/connection-profile/first-network.json`:
* Change `fabric-path` to your fabric network disk path in the first-network.json file:
* Modify connection profile in the JSON file `app/platform/fabric/connection-profile/test-network.json`:
* Change `fabric-path` to your fabric network disk path in the test-network.json file:
* Provide the full disk path to the adminPrivateKey config option, it ussually ends with `_sk`, for example:
`/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/aaacd899a6362a5c8cc1e6f86d13bfccc777375365bbda9c710bb7119993d71c_sk`
`/fabric-path/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/priv_sk`
* `adminUser` and `adminPassword` is the credential for user of Explorer to login the dashboard
* `enableAuthentication` is a flag to enable authentication using a login page, setting to false will skip authentication.

Expand Down
6 changes: 3 additions & 3 deletions app/platform/fabric/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"network-configs": {
"first-network": {
"name": "My first network",
"profile": "./connection-profile/first-network.json"
"test-network": {
"name": "Test Network",
"profile": "./connection-profile/test-network-ca.json"
}
},
"license": "Apache-2.0"
Expand Down
73 changes: 73 additions & 0 deletions app/platform/fabric/connection-profile/test-network-ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"name": "first-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"caCredential": {
"id": "admin",
"password": "adminpw"
},
"adminCredential": {
"id": "exploreradmin2",
"password": "exploreradminpw",
"affiliation": "org1.department1"
},
"enableAuthentication": true,
"organization": "Org1MSP",
"connection": {
"timeout": {
"peer": {
"endorser": "300"
},
"orderer": "300"
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
},
"connection": {
"timeout": {
"peer": {
"endorser": "6000",
"eventHub": "6000",
"eventReg": "6000"
}
}
}
}
},
"organizations": {
"Org1MSP": {
"mspid": "Org1MSP",
"peers": ["peer0.org1.example.com"],
"certificateAuthorities": ["ca0"]
}
},
"peers": {
"peer0.org1.example.com": {
"tlsCACerts": {
"path": "/home/atsushi/dev/hyperledger/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt"
},
"url": "grpcs://localhost:7051",
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca0": {
"url": "https://localhost:7054",
"httpOptions": {
"verify": false
},
"tlsCACerts": {
"path": "/home/atsushi/dev/hyperledger/fabric-samples/test-network/organizations/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
},
"caName": "ca0-org1"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
{
"name": "first-network",
"name": "test-network",
"version": "1.0.0",
"license": "Apache-2.0",
"client": {
"tlsEnable": true,
"caCredential": {
"id": "admin",
"password": "adminpw"
},
"adminCredential": {
"id": "exploreradmin",
"password": "exploreradminpw",
"affiliation": "org1.department1"
"password": "exploreradminpw"
},
"enableAuthentication": true,
"organization": "Org1MSP",
Expand Down Expand Up @@ -62,17 +57,5 @@
"ssl-target-name-override": "peer0.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca0": {
"url": "https://localhost:7054",
"httpOptions": {
"verify": false
},
"tlsCACerts": {
"path": "/fabric-path/fabric-samples/first-network/crypto-config/peerOrganizations/org1/ca/ca.org1-cert.pem"
},
"caName": "ca0-org1"
}
}
}
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:
volumes:
- ./examples/net1/config.json:/opt/explorer/app/platform/fabric/config.json
- ./examples/net1/connection-profile:/opt/explorer/app/platform/fabric/connection-profile
- ./examples/net1/crypto:/tmp/crypto
- /fabric-path/fabric-samples/test-network/organizations:/tmp/crypto
- walletstore:/opt/explorer/wallet
ports:
- 8080:8080
Expand Down
9 changes: 9 additions & 0 deletions examples/net1/config-ca.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"network-configs": {
"test-network": {
"name": "Test Network",
"profile": "./connection-profile/test-network-ca.json"
}
},
"license": "Apache-2.0"
}
6 changes: 3 additions & 3 deletions examples/net1/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"network-configs": {
"first-network": {
"name": "first-network",
"profile": "./connection-profile/first-network.json"
"test-network": {
"name": "Test Network",
"profile": "./connection-profile/test-network.json"
}
},
"license": "Apache-2.0"
Expand Down
Loading