This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/README.md

126 lines
5.5 KiB
Markdown
Raw Normal View History

2023-09-28 06:18:24 +00:00
# Devicehub
2023-09-29 08:03:42 +00:00
Devicehub is a distributed IT Asset Management System focused on reusing digital devices, created under the [eReuse.org](https://www.ereuse.org) initiative.
2023-09-28 06:18:24 +00:00
2024-02-16 19:18:17 +00:00
This README explains how to install and use Devicehub. [The documentation](http://devicehub.ereuse.org) explains the concepts, usage and the API it provides.
2023-09-28 06:18:24 +00:00
2023-09-29 08:03:42 +00:00
Devicehub is built with [Teal](https://github.com/ereuse/teal) and [Flask](http://flask.pocoo.org).
2024-02-16 19:18:17 +00:00
Devicehub relies on the existence of an [API_DLT connector](https://gitlab.com/dsg-upc/ereuse-dpp) verifiable data registry service, where specific operations are recorded to keep an external track record (ledger).
2023-09-28 06:18:24 +00:00
# Installing
2024-02-16 19:18:17 +00:00
Please visit the [Manual Installation](README_MANUAL_INSTALLATION.md) instructions to understand the detailed steps to install it locally or deploy it on a server. However, we recommend the following Docker deployment process.
2023-09-28 06:18:24 +00:00
# Docker
2024-02-16 19:18:17 +00:00
There is a Docker compose file for an automated deployment. The following steps describe how to run and use it.
2023-09-28 06:18:24 +00:00
1. Download the sources:
```
2024-02-08 11:34:55 +00:00
git clone https://github.com/eReuse/devicehub-teal.git -b oidc4vp
2023-09-28 06:18:24 +00:00
cd devicehub-teal
```
2024-02-16 19:18:17 +00:00
2. If you want to initialise your DeviceHub instance with sample device snapshots, copy it/them into that directory. e.g.
2023-09-28 06:18:24 +00:00
```
2023-09-29 12:29:00 +00:00
cp snapshot01.json examples/snapshots/
2023-09-28 06:18:24 +00:00
```
2024-02-16 19:18:17 +00:00
Otherwise, the device inventory of your DeviceHub instance will be empty and ready to add new devices. For that (no snapshot import), you need to change the var to 'n' in the **.env** file
2023-09-28 06:18:24 +00:00
```
2023-09-29 12:29:00 +00:00
IMPORT_SNAPSHOTS='n'
2023-09-28 06:18:24 +00:00
```
2024-02-16 19:18:17 +00:00
To register new devices, the [workbench software](https://github.com/eReuse/workbench) can be run on a device to generate its hardware snapshot that can be uploaded to your DeviceHub instance.
2023-09-29 08:03:42 +00:00
2024-02-16 19:18:17 +00:00
3. Setup the environment variables in the .env file. You can find one example in examples/env.example.
2023-09-29 08:03:42 +00:00
If you don't have any, you can copy that example and modify the basic vars
2023-09-28 06:18:24 +00:00
```
cp examples/env.example .env
```
2024-02-16 19:18:17 +00:00
You can use these parameters as default for a local test, but default values may not be suitable for an internet-exposed service for security reasons. However, these six variables need to be initialised:
2023-09-28 06:18:24 +00:00
```
API_DLT
API_DLT_TOKEN
API_RESOLVER
2024-02-08 11:34:55 +00:00
ABAC_TOKEN
ABAC_USER
ABAC_URL
2023-09-28 06:18:24 +00:00
```
2023-09-29 08:03:42 +00:00
These values should come from an already operational [API_DLT connector](https://gitlab.com/dsg-upc/ereuse-dpp) service instance.
2023-09-28 06:18:24 +00:00
2024-02-16 19:18:17 +00:00
If you want to use OIDC4VP, you need to set the vars:
2024-02-08 11:34:55 +00:00
```
SERVER_ID_FEDERATED
CLIENT_ID_FEDERATED
```
2024-02-16 19:18:17 +00:00
You can see the [manual install step 9]('https://github.com/eReuse/devicehub-teal/blob/oidc4vp/README_MANUAL_INSTALLATION.md#installing') for more details.
2024-02-08 11:34:55 +00:00
4. Build and run the docker containers:
2023-09-28 06:18:24 +00:00
```
./launcher.sh
2023-09-28 06:18:24 +00:00
```
2024-02-16 19:18:17 +00:00
To stop these docker containers, you can use Ctl+C. You'll maintain the data and infrastructure state if you run "compose up" again.
2023-09-28 14:37:02 +00:00
2023-09-29 08:03:42 +00:00
On the terminal screen, you can follow the installation steps. If there are any problems, error messages will appear here. The appearance of several warnings is normal and can be ignored.
2023-09-28 14:37:02 +00:00
2024-02-16 19:18:17 +00:00
If the last line you see one text like this, *exited with code*:
2023-09-28 14:37:02 +00:00
```
devicehub-teal-devicehub-id-client-1 exited with code 1
```
2023-09-29 08:03:42 +00:00
means the installation failed.
2023-09-28 06:18:24 +00:00
2023-09-28 15:57:56 +00:00
If the deployment was end-to-end successful (two running Devicehub instances successfully connected to the DLT backend selected in the .env file), you can see this text in the last lines:
```
devicehub-teal-devicehub-id-client-1 | * Running on http://172.28.0.2:5000/ (Press CTRL+C to quit)
devicehub-teal-devicehub-id-server-1 | * Running on all addresses.
devicehub-teal-devicehub-id-server-1 | WARNING: This is a development server. Do not use it in a production deployment.
devicehub-teal-devicehub-id-server-1 | * Running on http://172.28.0.5:5000/ (Press CTRL+C to quit)
```
2024-02-16 19:18:17 +00:00
That means the two Devicehub instances are running in their containers, which can be reached as http://localhost:5000/ and http://localhost:5001/
2023-09-29 08:03:42 +00:00
2024-02-16 19:18:17 +00:00
Once the DeviceHub instances are running, you might want to register a user binding to the DLT with the following commands (here, it assumes you want to execute it on devicehub-id-client, you might also want to do it in devicehub-id-server). Change the variables accordingly
```
FILE=my_users_devicehub.json
DOCKER_SERVICE=devicehub-id-server
docker compose cp /path/to/${FILE} ${DOCKER_SERVICE}:/tmp/
docker compose exec ${DOCKER_SERVICE} flask dlt_register_user /tmp/${FILE}
```
**my_users_devicehub.json** is a custom file which is similar to the one provided in `examples/users_devicehub.json`
2023-09-29 12:29:00 +00:00
5. To shut down the services and remove the corresponding data, you can use:
2023-09-28 06:18:24 +00:00
```
docker compose down -v
```
2023-09-29 08:03:42 +00:00
If you want to enter a shell inside a **new instance of the container**:
2023-09-28 06:18:24 +00:00
```
docker run -it --entrypoint= ${target_docker_image} bash
```
2023-09-29 08:03:42 +00:00
If you want to enter a shell on an **already running container**:
2023-09-28 06:18:24 +00:00
```
docker exec -it ${target_docker_image} bash
```
2023-09-28 14:37:02 +00:00
To know the valid value for ${target_docker_image} you can use:
2023-09-28 06:18:24 +00:00
```
docker ps
2023-09-28 06:24:03 +00:00
```
2023-09-29 12:29:00 +00:00
6. These are the details for use in this implementation:
2023-09-28 06:27:05 +00:00
2024-02-16 19:18:17 +00:00
Devicehub with URL (http://localhost:5000) is the identity provider of OIDC and have a user defined in **.env** file with SERVER_ID_EMAIL_DEMO var.
2023-09-28 06:27:05 +00:00
2024-02-16 19:18:17 +00:00
Devicehub with URL (http://localhost:5001) is the client identity of OIDC and have a user defined in **.env** file with SERVER_ID_EMAIL_DEMO var.
2023-09-28 06:24:03 +00:00
2023-09-28 14:37:02 +00:00
You can change these values in the *.env* file
2023-09-28 16:31:18 +00:00
2024-02-16 19:18:17 +00:00
7. If you want to use Workbench for these DeviceHub instances, you need to go to
2023-09-28 16:31:18 +00:00
```
http://localhost:5001/workbench/
```
2024-02-16 19:18:17 +00:00
with the demo user and then download the settings and ISO files. Follow the instructions on the [help](https://help.usody.com/en/setup/setup-pendrive/) page.