Skip to content

Commit

Permalink
fix linting errors in md files
Browse files Browse the repository at this point in the history
Signed-off-by: Musilah <[email protected]>
  • Loading branch information
Musilah committed Dec 16, 2024
1 parent 21a5f40 commit 143247b
Show file tree
Hide file tree
Showing 25 changed files with 176 additions and 207 deletions.
6 changes: 2 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
title: API
---

# API

## Reference

API reference in the Swagger UI can be found at: [https://api.magistrala.abstractmachines.fr][api]
Expand Down Expand Up @@ -2588,7 +2586,7 @@ Access-Control-Expose-Headers: Location
### Add policies
Only actions defined on [Predefined Policies section][predefined-policies] are allowed.
Only actions defined on Predefined Policies section are allowed.
```bash
curl -sSiX POST http://localhost/users/policies -H "Content-Type: application/json" -H "Authorization: Bearer <user_token>" -d @- << EOF
Expand Down Expand Up @@ -2643,7 +2641,7 @@ Access-Control-Expose-Headers: Location
### Update policies
Only actions defined on [Predefined Policies section][predefined-policies] are allowed.
Only actions defined on Predefined Policies section are allowed.
```bash
curl -sSiX PUT http://localhost/users/policies -H "Content-Type: application/json" -H "Authorization: Bearer <user_token>" -d @- << EOF
Expand Down
2 changes: 0 additions & 2 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
title: Architecture
---

# Architecture

## Components

SuperMQ IoT platform is comprised of the following services:
Expand Down
1 change: 0 additions & 1 deletion docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Authentication
---

# Authentication

## User authentication

Expand Down
2 changes: 0 additions & 2 deletions docs/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
title: Authorization
---

# Authorization

SuperMQ allows for fine-grained control over user permissions, taking into account hierarchical relationships between entities domains, groups, channels, and things. The structure and functionality of an authorization system implemented using [SpiceDB](https://github.com/authzed/spicedb) and its associated [schema language](https://authzed.com/docs/reference/schema-lang). `auth` service backed by SpiceDB manages permissions for users, domains, groups, channels, and things.

## Domains
Expand Down
6 changes: 2 additions & 4 deletions docs/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
title: Test Spec
---

# Test spec

## Tools

- [MZBench][mzbench]
Expand Down Expand Up @@ -121,15 +119,15 @@ Testing environment to be determined.

In this scenario, large number of requests are sent to HTTP adapter service every second. This test checks how much time HTTP adapter needs to respond to each request.

#### Results
#### Message Publishing Results

TBD

### Create and get client

In this scenario, large number of requests are sent to things service to create things and than to retrieve their data. This test checks how much time things service needs to respond to each request.

#### Results
#### Create and Get Client Results

TBD

Expand Down
125 changes: 61 additions & 64 deletions docs/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
title: Bootstrap
---

# Bootstrap

`Bootstrapping` refers to a self-starting process that is supposed to proceed without external input. SuperMQ platform supports bootstrapping process, but some of the preconditions need to be fulfilled in advance. The device can trigger a bootstrap when:s

- device contains only bootstrap credentials and no SuperMQ credentials
Expand Down Expand Up @@ -124,61 +122,60 @@ In order to disconnect, the same request should be sent with the value of `state

### Using curl request for secure bootstrap configuration

- *Encrypt the external key.*
- _Encrypt the external key._

First, encrypt the external key of your thing using AES encryption. The encryption key is specified by the `SMQ_BOOTSTRAP_ENCRYPT_KEY` environment variable. Use a library or utility that supports AES encryption to do this. Here's an example of how to encrypt using Go:

```go
package main

import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
)

type reader struct {
encKey []byte
encKey []byte
}

func (r reader) encrypt(in []byte) ([]byte, error) {
block, err := aes.NewCipher(r.encKey)
if err != nil {
return nil, err
}
ciphertext := make([]byte, aes.BlockSize+len(in))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
stream := cipher.NewCFBEncrypter(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], in)
return ciphertext, nil
block, err := aes.NewCipher(r.encKey)
if err != nil {
return nil, err
}
ciphertext := make([]byte, aes.BlockSize+len(in))
iv := ciphertext[:aes.BlockSize]
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
return nil, err
}
stream := cipher.NewCFBEncrypter(block, iv)
stream.XORKeyStream(ciphertext[aes.BlockSize:], in)
return ciphertext, nil
}

func main() {
data := []byte("<external_key>")
data := []byte("<external_key>")

r := reader{
encKey: []byte("<crypto_key>"),
}
r := reader{
encKey: []byte("<crypto_key>"),
}

encryptedData, err := r.encrypt(data)
if err != nil {
fmt.Println("Error encrypting data:", err)
return
}
encryptedData, err := r.encrypt(data)
if err != nil {
fmt.Println("Error encrypting data:", err)
return
}

fmt.Printf("%x\n", encryptedData)
fmt.Printf("%x\n", encryptedData)
}
```

Replace `<external_key>` and `<crypto_key>` with the thing's external key and `SMQ_BOOTSTRAP_ENCRYPT_KEY` respectively.

- *Make a request to the bootstrap service.*

- _Make a request to the bootstrap service._

Once the key is encrypted, make a request to the Bootstrap service. Here's how to do this using `curl`:

Expand All @@ -196,46 +193,46 @@ curl --location 'http://localhost:9013/things/bootstrap/secure/<external_id>' \
--header 'authorization: Thing <encyrpted_external_key>' --output ~/<desired\>/<path\>/<file_name.txt>
```

- *Decrypt the response*
- _Decrypt the response_

Finally, decrypt the response using a function. Here's an example of how to do this using Go:

```go
package main

import (
"crypto/aes"
"crypto/cipher"
"log"
"os"
"crypto/aes"
"crypto/cipher"
"log"
"os"
)

func main() {
encodedData, err := os.ReadFile("~/<desired\>/<path\>/<enc_file_name.txt>")
if err != nil {
log.Fatal(err)
}

key := []byte("<crypto_key>")

block, err := aes.NewCipher(key)
if err != nil {
log.Fatal(err)
}

if len(encodedData) < aes.BlockSize {
log.Fatal("ciphertext too short")
}

iv := encodedData[:aes.BlockSize]
encodedData = encodedData[aes.BlockSize:]
stream := cipher.NewCFBDecrypter(block, iv)
stream.XORKeyStream(encodedData, encodedData)

err = os.WriteFile("~/<desired\>/<path\>/<decry_file_name.txt>", encodedData, 0644)
if err != nil {
log.Fatal(err)
}
encodedData, err := os.ReadFile("~/<desired\>/<path\>/<enc_file_name.txt>")
if err != nil {
log.Fatal(err)
}

key := []byte("<crypto_key>")

block, err := aes.NewCipher(key)
if err != nil {
log.Fatal(err)
}

if len(encodedData) < aes.BlockSize {
log.Fatal("ciphertext too short")
}

iv := encodedData[:aes.BlockSize]
encodedData = encodedData[aes.BlockSize:]
stream := cipher.NewCFBDecrypter(block, iv)
stream.XORKeyStream(encodedData, encodedData)

err = os.WriteFile("~/<desired\>/<path\>/<decry_file_name.txt>", encodedData, 0644)
if err != nil {
log.Fatal(err)
}
}
```

Expand All @@ -246,13 +243,13 @@ To use SuperMQ CLI for the secure bootstrap configuration, use the following com
```bash
supermq-cli bootstrap secure <external_id> <external_key> <crypto_key>
```

for example

```bash
supermq-cli bootstrap bootstrap secure '09:6:0:sb:sa' 'key' 'v7aT0HGxJxt2gULzr3RHwf4WIf6DusPp'
```


For more information about the Bootstrap service API, please check out the [API documentation][api-docs].

[api-docs]: https://github.com/absmach/supermq/blob/main/api/openapi/bootstrap.yml
2 changes: 0 additions & 2 deletions docs/certs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Certs
---


# Certs

Provisioning is a process of configuration of an IoT platform in which system operator creates and sets-up different entities used in the platform - users, groups, channels and things.

## Certs Service
Expand Down
1 change: 0 additions & 1 deletion docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: CLI
---

# CLI

SuperMQ CLI makes it easy to manage users, things, channels and messages.

Expand Down
6 changes: 2 additions & 4 deletions docs/dev-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Developer's Guide
---

# Developer's guide

## Getting SuperMQ

Expand All @@ -17,7 +16,7 @@ cd $SOMEPATH/supermq

## Building

### Prerequisites
### Building Prerequisites

Make sure that you have [Protocol Buffers][protocol-buffers] (version 21.12) compiler (`protoc`) installed.

Expand Down Expand Up @@ -214,7 +213,7 @@ which will do this copying of the binaries.
## Deployment

### Prerequisites
### Deployment Prerequisites

SuperMQ depends on several infrastructural services, notably the default message broker, [NATS][nats] and [PostgreSQL][postgresql] database.

Expand Down Expand Up @@ -288,7 +287,6 @@ Please assure that MQTT microservice has `node_modules` installed, as explained
[cleanup-docker]: #cleaning-up-your-dockerized-supermq-setup
[docker-compose-ref]: https://docs.docker.com/compose/reference/overview/
[docker-compose-extend]: https://docs.docker.com/compose/extends/
[increase-nodes-memory]: https://medium.com/tomincode/increasing-nodes-memory-337dfb1a60dd
[go-cross-compile]: https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5
[go-arm]: https://www.alexruf.net/golang/arm/raspberrypi/2016/01/16/cross-compile-with-go-1-5-for-raspberry-pi.html
[wiki-go-arm]: https://go.dev/wiki/GoArm
Expand Down
2 changes: 0 additions & 2 deletions docs/edge.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Edge
---


# Edge

SuperMQ IoT platform provides services for supporting management of devices on the edge. Typically, IoT solution includes devices (sensors/actuators) deployed in far edge and connected through some proxy gateway. Although most devices could be connected to the SuperMQ directly, using gateways decentralizes system, decreases load on the cloud and makes setup less difficult. Also, gateways can provide additional data processing, filtering and storage.

Services that can be used on gateway to enable data and control plane for edge:
Expand Down
2 changes: 0 additions & 2 deletions docs/entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Entities
---


# Entities

Client is a component that will replace and unify the SuperMQ Things and Users services. The purpose is to represent generic client accounts. Each client is identified using its identity and secret. The client will differ from Things service to Users service but we aim to achieve 1:1 implementation between the clients whilst changing how client secret works. This includes client secret generation, usage, modification and storage

## Generic Client Entity
Expand Down
Loading

0 comments on commit 143247b

Please sign in to comment.