@adetante/explorer-besu-plugin 中文文档教程

发布于 4年前 浏览 3 项目主页 更新于 3年前

explorer-besu-plugin

构建

Alethio Explorer 插件,支持 Hyperledger Besu 身份验证。

Hyperledger Besu 支持在 JSON-RPC 端点上进行身份验证Authorization JSON-RPC 请求的标头。

此插件覆盖 eth-lite Web3DataSource 以处理 Besu 身份验证并注入身份验证标头。

用户名和密码保存在内存中,每 4 分钟刷新一次令牌(Besu 令牌在 5 分钟后过期)。

Installation instruction

有关完整的构建过程,请参阅 Alethio Lite Explorer 文档

主要步骤是:

# Clone ethereum-lite-explorer master branch
git clone git@github.com:Alethio/ethereum-lite-explorer.git
# Build
npm install
npm run build
# Install plugins
npm i -g @alethio/cms-plugin-tool
acp install \
    @alethio/explorer-plugin-eth-common \
    @alethio/explorer-plugin-eth-lite \
    @alethio/explorer-plugin-3box \
    @adetante/explorer-besu-plugin
# Copy/edit config.json to dist/ directory (see next section)

Configuration

:warning: 由于 eth-lite 插件要求身份验证数据适配器在初始化期间可用,因此必须在 plugin://aleth.io/eth-lite 之前加载此插件 在插件配置中。

config.json 中,添加以下插件定义:

"plugins": [
    ...
    {
        "uri": "plugin://adetante/besu?v=1.0.4,
        "config": {
            "loginUrl": "https://my_besu_node/login"
        }
    }
    ...
]
  • loginUrl is the login endpoint. When using Besu default username/password authentication, this URL is the JSON-RPC HTTP url with /login suffix. If you use Besu JWT public key authentication, this URL can point to your own token distribution endpoint. Your login endpoint must accept POST requests with body { "username": "xxx", "password": "xxx" } and return a JSON response with { "token": "xxx" }

plugin://aleth.io/eth-lite 配置更新为新数据适配器的链接:

"plugins": [
    ...,
    {
        "uri": "plugin://aleth.io/eth-lite?v=4.2.0",
        "config": {
            "nodeUrl": "https://my_besu_node",
            "authStoreUri": "adapter://adetante/besu/auth-store"
        }
    },
    ...
]
  • Add the authStoreUri attribute to the eth-lite configuration with the value adapter://adetante/besu/auth-store to link eth-lite to this plugin

Required Besu permissions

最低 JSON-RPC 权限< /a> 使用 Alethio Explorer 的要求是:

permissions = [
    "eth:getBlockByHash",
    "eth:getBlockByNumber",
    "eth:getBlockTransactionCountByHash",
    "eth:getBlockTransactionCountByNumber",
    "eth:blockNumber",
    "eth:getTransactionByHash",
    "eth:getTransactionReceipt",
    "eth:getBalance",
    "eth:getCode",
    "eth:getUncleByBlockHashAndIndex",
    "eth:getUncleByBlockNumberAndIndex",
    "net:peerCount"
]

在 Besu toml 凭据文件中定义。

Running in Docker

一个基于 ethereum-lite-explorer 的 Docker 镜像可以在 Docker Hub

只需

$ docker run -e APP_NODE_URL="https://my_besu_node" -p 80:80 adetante/explorer-besu-plugin:1.0.4

使用引用 Besu 节点的 JSON-RPC 端点的环境变量 APP_NODE_URL 运行。

此图像使用默认的 config.json 文件,并将 ${APP_NODE_URL} 设置为 nodeUrl for eth-lite插件和 ${APP_NODE_URL}/login 作为 Besu 插件的 loginUrl。 您可以通过在 /usr/share/nginx/html/config.json 中安装自定义配置文件来覆盖 config.json(请参阅 Alethio Explorer:在 Docker 中运行)

explorer-besu-plugin

Build

Alethio Explorer plugin that provides support for Hyperledger Besu authentication.

Hyperledger Besu supports authentication on JSON-RPC endpoint using a Bearer token in the Authorization header of JSON-RPC requests.

This plugin overrides the eth-lite Web3DataSource to handle Besu authentication and inject the authentication header.

Username and password are kept in memory to refresh the token every 4 minutes (Besu tokens expire after 5 minutes).

Installation instruction

See Alethio Lite Explorer documentation for the complete build procedure.

The main steps are:

# Clone ethereum-lite-explorer master branch
git clone git@github.com:Alethio/ethereum-lite-explorer.git
# Build
npm install
npm run build
# Install plugins
npm i -g @alethio/cms-plugin-tool
acp install \
    @alethio/explorer-plugin-eth-common \
    @alethio/explorer-plugin-eth-lite \
    @alethio/explorer-plugin-3box \
    @adetante/explorer-besu-plugin
# Copy/edit config.json to dist/ directory (see next section)

Configuration

:warning: As eth-lite plugin requires the authentication data adapter to be available during initialization, this plugin must be loaded BEFORE plugin://aleth.io/eth-lite in the plugins configuration.

In config.json, add the following plugin definition:

"plugins": [
    ...
    {
        "uri": "plugin://adetante/besu?v=1.0.4,
        "config": {
            "loginUrl": "https://my_besu_node/login"
        }
    }
    ...
]
  • loginUrl is the login endpoint. When using Besu default username/password authentication, this URL is the JSON-RPC HTTP url with /login suffix. If you use Besu JWT public key authentication, this URL can point to your own token distribution endpoint. Your login endpoint must accept POST requests with body { "username": "xxx", "password": "xxx" } and return a JSON response with { "token": "xxx" }

Update the plugin://aleth.io/eth-lite configuration with the link to the new data adapter:

"plugins": [
    ...,
    {
        "uri": "plugin://aleth.io/eth-lite?v=4.2.0",
        "config": {
            "nodeUrl": "https://my_besu_node",
            "authStoreUri": "adapter://adetante/besu/auth-store"
        }
    },
    ...
]
  • Add the authStoreUri attribute to the eth-lite configuration with the value adapter://adetante/besu/auth-store to link eth-lite to this plugin

Required Besu permissions

The minimum JSON-RPC permissions required to use Alethio Explorer are:

permissions = [
    "eth:getBlockByHash",
    "eth:getBlockByNumber",
    "eth:getBlockTransactionCountByHash",
    "eth:getBlockTransactionCountByNumber",
    "eth:blockNumber",
    "eth:getTransactionByHash",
    "eth:getTransactionReceipt",
    "eth:getBalance",
    "eth:getCode",
    "eth:getUncleByBlockHashAndIndex",
    "eth:getUncleByBlockNumberAndIndex",
    "net:peerCount"
]

To be defined in the Besu toml credentials file.

Running in Docker

A Docker image based on ethereum-lite-explorer is available on Docker Hub.

Just run

$ docker run -e APP_NODE_URL="https://my_besu_node" -p 80:80 adetante/explorer-besu-plugin:1.0.4

with the environment variable APP_NODE_URL referring to the JSON-RPC endpoint of Besu node.

This image uses the default config.json file, and sets ${APP_NODE_URL} as nodeUrl for eth-lite plugin and ${APP_NODE_URL}/login as loginUrl for Besu plugin. You can override config.json by mounting a custom configuration file in /usr/share/nginx/html/config.json (see Alethio Explorer: Running in Docker)

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文