Skip to content

Commit

Permalink
NOISSUE - Rename Things to Clients
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Gateru <[email protected]>
Signed-off-by: Arvindh <[email protected]>
  • Loading branch information
felixgateru authored and dborovcanin committed Nov 12, 2024
1 parent 9d14a75 commit c04c035
Show file tree
Hide file tree
Showing 211 changed files with 3,476 additions and 4,301 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
export DOMAIN_ID=$(curl -sSX POST $DOMAINS_URL -H "Content-Type: application/json" -H "Authorization: Bearer $USER_TOKEN" -d "{\"name\":\"$DOMAIN_NAME\",\"alias\":\"$DOMAIN_NAME\"}" | jq -r .id)
export USER_TOKEN=$(curl -sSX POST $TOKENS_URL -H "Content-Type: application/json" -d "{\"identity\": \"$USER_IDENTITY\",\"secret\": \"$USER_SECRET\",\"domain_id\": \"$DOMAIN_ID\"}" | jq -r .access_token)
echo "USER_TOKEN=$USER_TOKEN" >> $GITHUB_ENV
export THING_SECRET=$(magistrala-cli provision test | /usr/bin/grep -Eo '"secret": "[^"]+"' | awk 'NR % 2 == 0' | sed 's/"secret": "\(.*\)"/\1/')
echo "THING_SECRET=$THING_SECRET" >> $GITHUB_ENV
export CLIENT_SECRET=$(magistrala-cli provision test | /usr/bin/grep -Eo '"secret": "[^"]+"' | awk 'NR % 2 == 0' | sed 's/"secret": "\(.*\)"/\1/')
echo "CLIENT_SECRET=$CLIENT_SECRET" >> $GITHUB_ENV
- name: Check for changes in specific paths
uses: dorny/paths-filter@v3
Expand Down
12 changes: 6 additions & 6 deletions api/asyncapi/mqtt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ info:
license:
name: Apache 2.0
url: 'https://github.com/absmach/magistrala/blob/main/LICENSE'


defaultContentType: application/json

servers:
Expand All @@ -33,7 +33,7 @@ servers:
enum:
- '1883'
- '8883'
security:
security:
- user-password: []

channels:
Expand All @@ -45,7 +45,7 @@ channels:
required: true
subtopic:
$ref: '#/components/parameters/subtopic'
in: path
in: path
required: false

publish:
Expand Down Expand Up @@ -88,7 +88,7 @@ components:
parameters:
channelID:
description: Channel ID connected to the Thing ID defined in the username.
description: Channel ID connected to the Client ID defined in the username.
schema:
type: string
format: uuid
Expand All @@ -97,7 +97,7 @@ components:
schema:
type: string
default: ''

securitySchemes:
user-password:
type: userPassword
Expand Down
4 changes: 2 additions & 2 deletions api/asyncapi/websocket.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ components:
```
parameters:
channelID:
description: Channel ID connected to the Thing ID defined in the username.
description: Channel ID connected to the Client ID defined in the username.
schema:
type: string
format: uuid
Expand All @@ -141,4 +141,4 @@ components:
scheme: bearer
bearerFormat: uuid
description: |
* Thing access: "Authorization: Thing <client_key>"
* Client access: "Authorization: Client <client_key>"
2 changes: 1 addition & 1 deletion api/openapi/auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ components:
metadata:
type: object
example: { "domain": "example.com" }
description: Arbitrary, object-encoded thing's data.
description: Arbitrary, object-encoded client's data.
alias:
type: string
example: domain alias
Expand Down
38 changes: 19 additions & 19 deletions api/openapi/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ paths:
description: |
Update is performed by replacing the current resource data with values
provided in a request payload. Note that the owner, ID, external ID,
external key, Magistrala Thing ID and key cannot be changed.
external key, Magistrala Client ID and key cannot be changed.
tags:
- configs
parameters:
Expand Down Expand Up @@ -205,7 +205,7 @@ paths:
summary: Updates channels the client is connected to
description: |
Update connections performs update of the channel list corresponding
Thing is connected to.
Client is connected to.
tags:
- configs
parameters:
Expand Down Expand Up @@ -287,7 +287,7 @@ paths:
summary: Updates Config state.
description: |
Updating state represents enabling/disabling Config, i.e. connecting
and disconnecting corresponding Magistrala Thing to the list of Channels.
and disconnecting corresponding Magistrala Client to the list of Channels.
tags:
- configs
parameters:
Expand Down Expand Up @@ -333,11 +333,11 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Thing ID.
description: Corresponding Magistrala Client ID.
magistrala_secret:
type: string
format: uuid
description: Corresponding Magistrala Thing key.
description: Corresponding Magistrala Client key.
channels:
type: array
minItems: 0
Expand Down Expand Up @@ -405,11 +405,11 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Thing ID.
thing_key:
description: Corresponding Magistrala Client ID.
client_key:
type: string
format: uuid
description: Corresponding Magistrala Thing key.
description: Corresponding Magistrala Client key.
channels:
type: array
minItems: 0
Expand All @@ -429,7 +429,7 @@ components:
description: Issuing CA certificate.
required:
- client_id
- thing_key
- client_key
- channels
- content
ConfigUpdateCerts:
Expand All @@ -438,7 +438,7 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Thing ID.
description: Corresponding Magistrala Client ID.
client_cert:
type: string
description: Client certificate.
Expand All @@ -450,14 +450,14 @@ components:
description: Issuing CA certificate.
required:
- client_id
- thing_key
- client_key
- channels
- content

parameters:
ConfigId:
name: configId
description: Unique Config identifier. It's the ID of the corresponding Thing.
description: Unique Config identifier. It's the ID of the corresponding Client.
in: path
schema:
type: string
Expand Down Expand Up @@ -522,7 +522,7 @@ components:
client_id:
type: string
format: uuid
description: ID of the corresponding Magistrala Thing.
description: ID of the corresponding Magistrala Client.
channels:
type: array
minItems: 0
Expand All @@ -535,17 +535,17 @@ components:
type: string
client_cert:
type: string
description: Thing Certificate.
description: Client Certificate.
client_key:
type: string
description: Thing Private Key.
description: Client Private Key.
ca_cert:
type: string
required:
- external_id
- external_key
ConfigUpdateReq:
description: JSON-formatted document describing the updated thing.
description: JSON-formatted document describing the updated client.
content:
application/json:
schema:
Expand All @@ -559,7 +559,7 @@ components:
- content
- name
ConfigCertUpdateReq:
description: JSON-formatted document describing the updated thing.
description: JSON-formatted document describing the updated client.
content:
application/json:
schema:
Expand Down Expand Up @@ -673,14 +673,14 @@ components:
scheme: bearer
bearerFormat: string
description: |
* Clients access: "Authorization: Thing <external_key>"
* Clients access: "Authorization: Client <external_key>"
bootstrapEncAuth:
type: http
scheme: bearer
bearerFormat: aes-sha256-uuid
description: |
* Clients access: "Authorization: Thing <external_enc_key>"
* Clients access: "Authorization: Client <external_enc_key>"
Hex-encoded configuration external key encrypted using
the AES algorithm and SHA256 sum of the external key
itself as an encryption key.
Expand Down
10 changes: 5 additions & 5 deletions api/openapi/certs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ paths:
/{domainID}/certs:
post:
operationId: createCert
summary: Creates a certificate for thing
description: Creates a certificate for thing
summary: Creates a certificate for client
description: Creates a certificate for client
tags:
- certs
parameters:
Expand Down Expand Up @@ -171,7 +171,7 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Thing ID.
description: Corresponding Magistrala Client ID.
client_cert:
type: string
description: Client Certificate.
Expand Down Expand Up @@ -240,7 +240,7 @@ components:
requestBodies:
CertReq:
description: |
Issues a certificate that is required for mTLS. To create a certificate for a thing
Issues a certificate that is required for mTLS. To create a certificate for a client
provide a client id, data identifying particular client will be embedded into the Certificate.
x509 and ECC certificates are supported when using when Vault is used as PKI.
content:
Expand Down Expand Up @@ -271,7 +271,7 @@ components:
serial:
operationId: getSerials
parameters:
thingID: $response.body#/client_id
clientID: $response.body#/client_id
delete:
operationId: revokeCert
parameters:
Expand Down
4 changes: 2 additions & 2 deletions api/openapi/http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ components:
scheme: bearer
bearerFormat: uuid
description: |
* Thing access: "Authorization: Thing <client_key>"
* Client access: "Authorization: Client <client_key>"
basicAuth:
type: http
scheme: basic
description: |
* Things access: "Authorization: Basic <base64-encoded_credentials>"
* Clients access: "Authorization: Basic <base64-encoded_credentials>"
security:
- bearerAuth: []
Expand Down
4 changes: 2 additions & 2 deletions api/openapi/journal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ components:
parameters:
entity_type:
name: entity_type
description: Type of entity, e.g. user, group, thing, etc.
description: Type of entity, e.g. user, group, client, etc.
in: path
schema:
type: string
enum:
- user
- group
- thing
- client
- channel
required: true
example: user
Expand Down
6 changes: 3 additions & 3 deletions api/openapi/readers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ components:
description: |
* Users access: "Authorization: Bearer <user_token>"
thingAuth:
clientAuth:
type: http
scheme: bearer
bearerFormat: uuid
description: |
* Things access: "Authorization: Thing <client_key>"
* Clients access: "Authorization: Client <client_key>"
security:
- bearerAuth: []
- thingAuth: []
- clientAuth: []
2 changes: 1 addition & 1 deletion auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Authentication keys are represented and distributed by the corresponding [JWT](j

User keys are issued when user logs in. Each user request (other than `registration` and `login`) contains user key that is used to authenticate the user.

API keys are similar to the User keys. The main difference is that API keys have configurable expiration time. If no time is set, the key will never expire. For that reason, API keys are _the only key type that can be revoked_. This also means that, despite being used as a JWT, it requires a query to the database to validate the API key. The user with API key can perform all the same actions as the user with login key (can act on behalf of the user for Thing, Channel, or user profile management), _except issuing new API keys_.
API keys are similar to the User keys. The main difference is that API keys have configurable expiration time. If no time is set, the key will never expire. For that reason, API keys are _the only key type that can be revoked_. This also means that, despite being used as a JWT, it requires a query to the database to validate the API key. The user with API key can perform all the same actions as the user with login key (can act on behalf of the user for Client, Channel, or user profile management), _except issuing new API keys_.

Recovery key is the password recovery key. It's short-lived token used for password recovery process.

Expand Down
32 changes: 16 additions & 16 deletions bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

New devices need to be configured properly and connected to the Magistrala. Bootstrap service is used in order to accomplish that. This service provides the following features:

1. Creating new Magistrala Things
2. Providing basic configuration for the newly created Things
3. Enabling/disabling Things
1. Creating new Magistrala Clients
2. Providing basic configuration for the newly created Clients
3. Enabling/disabling Clients

Pre-provisioning a new Thing is as simple as sending Configuration data to the Bootstrap service. Once the Thing is online, it sends a request for initial config to Bootstrap service. Bootstrap service provides an API for enabling and disabling Things. Only enabled Things can exchange messages over Magistrala. Bootstrapping does not implicitly enable Things, it has to be done manually.
Pre-provisioning a new Client is as simple as sending Configuration data to the Bootstrap service. Once the Client is online, it sends a request for initial config to Bootstrap service. Bootstrap service provides an API for enabling and disabling Clients. Only enabled Clients can exchange messages over Magistrala. Bootstrapping does not implicitly enable Clients, it has to be done manually.

In order to bootstrap successfully, the Thing needs to send bootstrapping request to the specific URL, as well as a secret key. This key and URL are pre-provisioned during the manufacturing process. If the Thing is provisioned on the Bootstrap service side, the corresponding configuration will be sent as a response. Otherwise, the Thing will be saved so that it can be provisioned later.
In order to bootstrap successfully, the Client needs to send bootstrapping request to the specific URL, as well as a secret key. This key and URL are pre-provisioned during the manufacturing process. If the Client is provisioned on the Bootstrap service side, the corresponding configuration will be sent as a response. Otherwise, the Client will be saved so that it can be provisioned later.

## Thing Configuration Entity
## Client Configuration Entity

Thing Configuration consists of two logical parts: the custom configuration that can be interpreted by the Thing itself and Magistrala-related configuration. Magistrala config contains:
Client Configuration consists of two logical parts: the custom configuration that can be interpreted by the Client itself and Magistrala-related configuration. Magistrala config contains:

1. corresponding Magistrala Thing ID
2. corresponding Magistrala Thing key
3. list of the Magistrala channels the Thing is connected to
1. corresponding Magistrala Client ID
2. corresponding Magistrala Client key
3. list of the Magistrala channels the Client is connected to

> Note: list of channels contains IDs of the Magistrala channels. These channels are _pre-provisioned_ on the Magistrala side and, unlike corresponding Magistrala Thing, Bootstrap service is not able to create Magistrala Channels.
> Note: list of channels contains IDs of the Magistrala channels. These channels are _pre-provisioned_ on the Magistrala side and, unlike corresponding Magistrala Client, Bootstrap service is not able to create Magistrala Channels.
Enabling and disabling Thing (adding Thing to/from whitelist) is as simple as connecting corresponding Magistrala Thing to the given list of Channels. Configuration keeps _state_ of the Thing:
Enabling and disabling Client (adding Client to/from whitelist) is as simple as connecting corresponding Magistrala Client to the given list of Channels. Configuration keeps _state_ of the Client:

| State | What it means |
| -------- | --------------------------------------------- |
| Inactive | Thing is created, but isn't enabled |
| Active | Thing is able to communicate using Magistrala |
| Inactive | Client is created, but isn't enabled |
| Active | Client is able to communicate using Magistrala |

Switching between states `Active` and `Inactive` enables and disables Thing, respectively.
Switching between states `Active` and `Inactive` enables and disables Client, respectively.

Thing configuration also contains the so-called `external ID` and `external key`. An external ID is a unique identifier of corresponding Thing. For example, a device MAC address is a good choice for external ID. External key is a secret key that is used for authentication during the bootstrapping procedure.
Client configuration also contains the so-called `external ID` and `external key`. An external ID is a unique identifier of corresponding Client. For example, a device MAC address is a good choice for external ID. External key is a secret key that is used for authentication during the bootstrapping procedure.

## Configuration

Expand Down
2 changes: 1 addition & 1 deletion bootstrap/api/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func updateCertEndpoint(svc bootstrap.Service) endpoint.Endpoint {
return nil, svcerr.ErrAuthorization
}

cfg, err := svc.UpdateCert(ctx, session, req.thingID, req.ClientCert, req.ClientKey, req.CACert)
cfg, err := svc.UpdateCert(ctx, session, req.clientID, req.ClientCert, req.ClientKey, req.CACert)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit c04c035

Please sign in to comment.