SMQ-2533 - Rename Magistrala to SuperMQ (#2560)

Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
This commit is contained in:
Dušan Borovčanin
2024-12-04 11:17:09 +01:00
committed by GitHub
parent 10bc218dee
commit 178aa46ad4
748 changed files with 7502 additions and 7507 deletions
+1 -1
View File
@@ -1 +1 @@
* @absmach/magistrala
* @absmach/supermq
+2 -2
View File
@@ -5,7 +5,7 @@ blank_issues_enabled: false
contact_links:
- name: Google group
url: https://groups.google.com/forum/#!forum/mainflux
about: Join the Magistrala community on Google group.
about: Join the SuperMQ community on Google group.
- name: Gitter
url: https://gitter.im/mainflux/mainflux
about: Join the Magistrala community on Gitter.
about: Join the SuperMQ community on Gitter.
+2 -2
View File
@@ -3,8 +3,8 @@ SPDX-License-Identifier: Apache-2.0 -->
<!--
Pull request title should be `MG-XXX - description` or `NOISSUE - description` where XXX is ID of the issue that this PR relate to.
Please review the [CONTRIBUTING.md](https://github.com/absmach/magistrala/blob/main/CONTRIBUTING.md) file for detailed contributing guidelines.
Pull request title should be `SMQ-XXX - description` or `NOISSUE - description` where XXX is ID of the issue that this PR relate to.
Please review the [CONTRIBUTING.md](https://github.com/absmach/supermq/blob/main/CONTRIBUTING.md) file for detailed contributing guidelines.
For Work In Progress Pull Requests, please use the Draft PR feature, see https://github.blog/2019-02-14-introducing-draft-pull-requests/ for further details.
+1 -1
View File
@@ -65,7 +65,7 @@ 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 CLIENT_SECRET=$(magistrala-cli provision test | /usr/bin/grep -Eo '"secret": "[^"]+"' | awk 'NR % 2 == 0' | sed 's/"secret": "\(.*\)"/\1/')
export CLIENT_SECRET=$(supermq-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
+2 -2
View File
@@ -51,11 +51,11 @@ jobs:
- name: Compile check for rabbitmq
run: |
MG_MESSAGE_BROKER_TYPE=rabbitmq make mqtt
SMQ_MESSAGE_BROKER_TYPE=rabbitmq make mqtt
- name: Compile check for redis
run: |
MG_ES_TYPE=redis make mqtt
SMQ_ES_TYPE=redis make mqtt
- name: Build and push Dockers
run: |
+1 -2
View File
@@ -74,12 +74,11 @@ jobs:
- "certs/pki/vault.go"
- "certs/service.go"
- "journal/journal.go"
- "magistrala/auth_grpc.pb.go"
- name: Set up protoc
if: steps.changes.outputs.proto == 'true'
run: |
PROTOC_VERSION=28.3
PROTOC_VERSION=29.0
PROTOC_GEN_VERSION=v1.35.2
PROTOC_GRPC_VERSION=v1.5.1
+2 -2
View File
@@ -43,11 +43,11 @@ jobs:
- name: Compile check for rabbitmq
run: |
MG_MESSAGE_BROKER_TYPE=rabbitmq make mqtt
SMQ_MESSAGE_BROKER_TYPE=rabbitmq make mqtt
- name: Compile check for redis
run: |
MG_ES_TYPE=redis make mqtt
SMQ_ES_TYPE=redis make mqtt
run-tests:
name: Run tests
+6 -6
View File
@@ -1,12 +1,12 @@
# Adopters
As Magistrala Community grows, we'd like to keep track of Magistrala adopters to grow the community, contact other users, share experiences and best practices.
As SuperMQ Community grows, we'd like to keep track of SuperMQ adopters to grow the community, contact other users, share experiences and best practices.
To accomplish this, we created a public ledger. The list of organizations and users who consider themselves as Magistrala adopters and that **publicly/officially** shared information and/or details of their adoption journey(optional).
To accomplish this, we created a public ledger. The list of organizations and users who consider themselves as SuperMQ adopters and that **publicly/officially** shared information and/or details of their adoption journey(optional).
Where users themselves directly maintain the list.
## Adding yourself as an adopter
If you are using Magistrala, please consider adding yourself as an adopter with a brief description of your use case by opening a pull request to this file and adding a section describing your adoption of Magistrala technology.
If you are using SuperMQ, please consider adding yourself as an adopter with a brief description of your use case by opening a pull request to this file and adding a section describing your adoption of SuperMQ technology.
**Please send PRs to add or remove organizations/users**
@@ -25,12 +25,12 @@ Pull request commit must be [signed](https://docs.github.com/en/github/authentic
* There is no minimum requirement or adaptation size, but we request to list permanent deployments only, i.e., no demo or trial deployments. Commercial or production use is not required. A well-done home lab setup can be equally impressive as a large-scale commercial deployment.
**The list of organizations/users that have publicly shared the usage of Magistrala:**
**The list of organizations/users that have publicly shared the usage of SuperMQ:**
**Note**: Several other organizations/users couldn't publicly share their usage details but are active project contributors and Magistrala Community members.
**Note**: Several other organizations/users couldn't publicly share their usage details but are active project contributors and SuperMQ Community members.
## Adopters list (alphabetical)
**Note:** The list is maintained by the users themselves. If you find yourself on this list, and you think it's inappropriate. Please contact [project maintainers](https://github.com/absmach/magistrala/blob/main/MAINTAINERS) and you will be permanently removed from the list.
**Note:** The list is maintained by the users themselves. If you find yourself on this list, and you think it's inappropriate. Please contact [project maintainers](https://github.com/absmach/supermq/blob/main/MAINTAINERS) and you will be permanently removed from the list.
+11 -11
View File
@@ -1,11 +1,11 @@
# Contributing to Magistrala
# Contributing to SuperMQ
The following is a set of guidelines to contribute to Magistrala and its libraries, which are
The following is a set of guidelines to contribute to SuperMQ and its libraries, which are
hosted on the [Abstract Machines Organization](https://github.com/absmach) on GitHub.
This project adheres to the [Contributor Covenant 1.2](http://contributor-covenant.org/version/1/2/0).
By participating, you are expected to uphold this code. Please report unacceptable behavior to
[abuse@magistrala.com](mailto:abuse@magistrala.com).
[abuse@abstractmachines.fr](mailto:abuse@abstractmachines.fr).
## Reporting issues
@@ -13,7 +13,7 @@ Reporting issues are a great way to contribute to the project. We are perpetuall
thorough bug report.
Before raising a new issue, check [our issue
list](https://github.com/absmach/magistrala/issues) to determine if it already contains the
list](https://github.com/absmach/supermq/issues) to determine if it already contains the
problem that you are facing.
A good bug report shouldn't leave others needing to chase you for more information. Please be as detailed as possible. The following questions might serve as a template for writing a detailed
@@ -41,23 +41,23 @@ To contribute to the project, [fork](https://help.github.com/articles/fork-a-rep
clone your fork repository, and configure the remotes:
```
git clone https://github.com/<your-username>/magistrala.git
cd magistrala
git remote add upstream https://github.com/absmach/magistrala.git
git clone https://github.com/<your-username>/supermq.git
cd supermq
git remote add upstream https://github.com/absmach/supermq.git
```
If your cloned repository is behind the upstream commits, then get the latest changes from upstream:
```
git checkout master
git checkout main
git pull --rebase upstream main
```
Create a new topic branch from `master` using the naming convention `MG-[issue-number]`
Create a new topic branch from `main` using the naming convention `SMQ-[issue-number]`
to help us keep track of your contribution scope:
```
git checkout -b MG-[issue-number]
git checkout -b SMQ-[issue-number]
```
Commit your changes in logical chunks. When you are ready to commit, make sure
@@ -80,7 +80,7 @@ git pull --rebase upstream main
Push your topic branch up to your fork:
```
git push origin MG-[issue-number]
git push origin SMQ-[issue-number]
```
[Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title
+1 -1
View File
@@ -176,7 +176,7 @@
END OF TERMS AND CONDITIONS
Copyright 2015-2020 Magistrala
Copyright 2015-2020 SuperMQ
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,4 +1,4 @@
# Magistrala follows the timeless, highly efficient and totally unfair system
# SuperMQ follows the timeless, highly efficient and totally unfair system
# known as [Benevolent dictator for
# life](https://en.wikipedia.org/wiki/Benevolent_Dictator_for_Life), with
# Drasko DRASKOVIC in the role of BDFL.
@@ -18,7 +18,7 @@
# Maintainers have the special role in the project in managing and accepting PRs,
# overall leading the project and making design decisions on the maintained subsystems.
#
# A reference list of all maintainers of the Magistrala project.
# A reference list of all maintainers of the SuperMQ project.
# ADD YOURSELF HERE IN ALPHABETICAL ORDER
+15 -15
View File
@@ -1,7 +1,7 @@
# Copyright (c) Abstract Machines
# SPDX-License-Identifier: Apache-2.0
MG_DOCKER_IMAGE_NAME_PREFIX ?= supermq
SMQ_DOCKER_IMAGE_NAME_PREFIX ?= supermq
BUILD_DIR ?= build
SERVICES = auth users clients groups channels domains http coap ws postgres-writer postgres-reader timescale-writer \
timescale-reader cli bootstrap mqtt provision certs invitations journal
@@ -27,21 +27,21 @@ INTERNAL_PROTO_GEN_OUT_DIR=internal/grpc
INTERNAL_PROTO_DIR=internal/proto
INTERNAL_PROTO_FILES := $(shell find $(INTERNAL_PROTO_DIR) -name "*.proto" | sed 's|$(INTERNAL_PROTO_DIR)/||')
ifneq ($(MG_MESSAGE_BROKER_TYPE),)
MG_MESSAGE_BROKER_TYPE := $(MG_MESSAGE_BROKER_TYPE)
ifneq ($(SMQ_MESSAGE_BROKER_TYPE),)
SMQ_MESSAGE_BROKER_TYPE := $(SMQ_MESSAGE_BROKER_TYPE)
else
MG_MESSAGE_BROKER_TYPE=nats
SMQ_MESSAGE_BROKER_TYPE=nats
endif
ifneq ($(MG_ES_TYPE),)
MG_ES_TYPE := $(MG_ES_TYPE)
ifneq ($(SMQ_ES_TYPE),)
SMQ_ES_TYPE := $(SMQ_ES_TYPE)
else
MG_ES_TYPE=nats
SMQ_ES_TYPE=nats
endif
define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -tags $(MG_MESSAGE_BROKER_TYPE) --tags $(MG_ES_TYPE) -ldflags "-s -w \
go build -tags $(SMQ_MESSAGE_BROKER_TYPE) --tags $(SMQ_ES_TYPE) -ldflags "-s -w \
-X 'github.com/absmach/supermq.BuildTime=$(TIME)' \
-X 'github.com/absmach/supermq.Version=$(VERSION)' \
-X 'github.com/absmach/supermq.Commit=$(COMMIT)'" \
@@ -59,7 +59,7 @@ define make_docker
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg TIME=$(TIME) \
--tag=$(MG_DOCKER_IMAGE_NAME_PREFIX)/$(svc) \
--tag=$(SMQ_DOCKER_IMAGE_NAME_PREFIX)/$(svc) \
-f docker/Dockerfile .
endef
@@ -69,7 +69,7 @@ define make_docker_dev
docker build \
--no-cache \
--build-arg SVC=$(svc) \
--tag=$(MG_DOCKER_IMAGE_NAME_PREFIX)/$(svc) \
--tag=$(SMQ_DOCKER_IMAGE_NAME_PREFIX)/$(svc) \
-f docker/Dockerfile.dev ./build
endef
@@ -110,12 +110,12 @@ cleandocker:
ifdef pv
# Remove unused volumes
docker volume ls -f name=$(MG_DOCKER_IMAGE_NAME_PREFIX) -f dangling=true -q | xargs -r docker volume rm
docker volume ls -f name=$(SMQ_DOCKER_IMAGE_NAME_PREFIX) -f dangling=true -q | xargs -r docker volume rm
endif
install:
for file in $(BUILD_DIR)/*; do \
cp $$file $(GOBIN)/magistrala-`basename $$file`; \
cp $$file $(GOBIN)/supermq-`basename $$file`; \
done
mocks:
@@ -200,7 +200,7 @@ dockers_dev: $(DOCKERS_DEV)
define docker_push
for svc in $(SERVICES); do \
docker push $(MG_DOCKER_IMAGE_NAME_PREFIX)/$$svc:$(1); \
docker push $(SMQ_DOCKER_IMAGE_NAME_PREFIX)/$$svc:$(1); \
done
endef
@@ -215,7 +215,7 @@ release:
git checkout $(version)
$(MAKE) dockers
for svc in $(SERVICES); do \
docker tag $(MG_DOCKER_IMAGE_NAME_PREFIX)/$$svc $(MG_DOCKER_IMAGE_NAME_PREFIX)/$$svc:$(version); \
docker tag $(SMQ_DOCKER_IMAGE_NAME_PREFIX)/$$svc $(SMQ_DOCKER_IMAGE_NAME_PREFIX)/$$svc:$(version); \
done
$(call docker_push,$(version))
@@ -260,7 +260,7 @@ run: check_certs
run_addons: check_certs
$(foreach SVC,$(RUN_ADDON_ARGS),$(if $(filter $(SVC),$(ADDON_SERVICES) $(EXTERNAL_SERVICES)),,$(error Invalid Service $(SVC))))
@for SVC in $(RUN_ADDON_ARGS); do \
MG_ADDONS_CERTS_PATH_PREFIX="../." docker compose -f docker/addons/$$SVC/docker-compose.yml -p $(DOCKER_PROJECT) --env-file ./docker/.env $(DOCKER_COMPOSE_COMMAND) $(args) & \
SMQ_ADDONS_CERTS_PATH_PREFIX="../." docker compose -f docker/addons/$$SVC/docker-compose.yml -p $(DOCKER_PROJECT) --env-file ./docker/.env $(DOCKER_COMPOSE_COMMAND) $(args) & \
done
run_live: check_certs
+2 -2
View File
@@ -59,7 +59,7 @@ make run
```
If you want to run services from specific release checkout code from github and make sure that
`MG_RELEASE_TAG` in [.env](.env) is being set to match the release version
`SMQ_RELEASE_TAG` in [.env](.env) is being set to match the release version
```bash
git checkout tags/<release_number> -b <release_number>
@@ -69,7 +69,7 @@ git checkout tags/<release_number> -b <release_number>
Check that `.env` file contains:
```bash
MG_RELEASE_TAG=<release_number>
SMQ_RELEASE_TAG=<release_number>
```
> `docker-compose` should be used for development and testing deployments. For production we suggest using [Kubernetes](https://docs.supermq.abstractmachines.fr/kubernetes).
+1 -1
View File
@@ -1,7 +1,7 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
package magistrala
package supermq
// Response contains HTTP response specific methods.
type Response interface {
+5 -5
View File
@@ -2,13 +2,13 @@
# SPDX-License-Identifier: Apache-2.0
asyncapi: '2.6.0'
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/mqtt.yml'
id: 'https://github.com/absmach/supermq/blob/main/api/asyncapi/mqtt.yml'
info:
title: Magistrala MQTT Adapter
title: SuperMQ MQTT Adapter
version: '1.0.0'
contact:
name: Magistrala Team
url: 'https://github.com/absmach/magistrala'
name: SuperMQ Team
url: 'https://github.com/absmach/supermq'
email: info@abstractmachines.fr
description: |
MQTT adapter provides an MQTT API for sending messages through the platform. MQTT adapter uses [mProxy](https://github.com/absmach/mproxy) for proxying traffic between client and MQTT broker.
@@ -16,7 +16,7 @@ info:
license:
name: Apache 2.0
url: 'https://github.com/absmach/magistrala/blob/main/LICENSE'
url: 'https://github.com/absmach/supermq/blob/main/LICENSE'
defaultContentType: application/json
+7 -7
View File
@@ -2,18 +2,18 @@
# SPDX-License-Identifier: Apache-2.0
asyncapi: 2.6.0
id: 'https://github.com/absmach/magistrala/blob/main/api/asyncapi/websocket.yml'
id: 'https://github.com/absmach/supermq/blob/main/api/asyncapi/websocket.yml'
info:
title: Magistrala WebSocket adapter
title: SuperMQ WebSocket adapter
description: WebSocket adapter provides a WebSocket API for sending messages through communication channels. WebSocket adapter uses [mProxy](https://github.com/absmach/mproxy) for proxying traffic between client and MQTT broker.
version: '1.0.0'
contact:
name: Magistrala Team
url: 'https://github.com/absmach/magistrala'
name: SuperMQ Team
url: 'https://github.com/absmach/supermq'
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: 'https://github.com/absmach/magistrala/blob/main/LICENSE'
url: 'https://github.com/absmach/supermq/blob/main/LICENSE'
tags:
- name: WebSocket
defaultContentType: application/json
@@ -28,7 +28,7 @@ servers:
description: Hostname of the WebSocket adapter
default: localhost
port:
description: Magistrala WebSocket Adapter port
description: SuperMQ WebSocket Adapter port
default: '8186'
channels:
@@ -70,7 +70,7 @@ channels:
- bearerAuth: []
/version:
subscribe:
summary: Get the version of the Magistrala adapter
summary: Get the version of the SuperMQ adapter
operationId: getVersion
bindings:
http:
+3 -3
View File
@@ -1,5 +1,5 @@
# Magistrala OpenAPI Specification
# SuperMQ OpenAPI Specification
This folder contains an OpenAPI specifications for Magistrala API.
This folder contains an OpenAPI specifications for SuperMQ API.
View specification in Swagger UI at [docs.api.magistrala.abstractmachines.fr](https://docs.api.magistrala.abstractmachines.fr)
View specification in Swagger UI at [docs.api.magistrala.abstractmachines.fr](https://docs.api.supermq.abstractmachines.fr)
+6 -6
View File
@@ -3,16 +3,16 @@
openapi: 3.0.3
info:
title: Magistrala Auth Service
title: SuperMQ Auth Service
description: |
This is the Auth Server based on the OpenAPI 3.0 specification. It is the HTTP API for managing platform users. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,19 +24,19 @@ tags:
description: Everything about your Keys.
externalDocs:
description: Find out more about keys
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
- name: Domains
description: Everything about your Domains.
externalDocs:
description: Find out more about domains
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
- name: Health
description: Service health check endpoint.
externalDocs:
description: Find out more about health check
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
+13 -13
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala Bootstrap service
title: SuperMQ Bootstrap service
description: |
HTTP API for managing platform clients configuration.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Configs
externalDocs:
description: Find out more about Configs
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/{domainID}/clients/configs:
@@ -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 Client ID and key cannot be changed.
external key, SuperMQ Client ID and key cannot be changed.
tags:
- configs
parameters:
@@ -148,7 +148,7 @@ paths:
summary: Removes a Config
description: |
Removes a Config. In case of successful removal the service will ensure
that the removed config is disconnected from all of the Magistrala channels.
that the removed config is disconnected from all of the SuperMQ channels.
tags:
- configs
parameters:
@@ -287,7 +287,7 @@ paths:
summary: Updates Config state.
description: |
Updating state represents enabling/disabling Config, i.e. connecting
and disconnecting corresponding Magistrala Client to the list of Channels.
and disconnecting corresponding SuperMQ Client to the list of Channels.
tags:
- configs
parameters:
@@ -333,11 +333,11 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Client ID.
description: Corresponding SuperMQ Client ID.
magistrala_secret:
type: string
format: uuid
description: Corresponding Magistrala Client key.
description: Corresponding SuperMQ Client key.
channels:
type: array
minItems: 0
@@ -405,11 +405,11 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Client ID.
description: Corresponding SuperMQ Client ID.
client_key:
type: string
format: uuid
description: Corresponding Magistrala Client key.
description: Corresponding SuperMQ Client key.
channels:
type: array
minItems: 0
@@ -438,7 +438,7 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Client ID.
description: Corresponding SuperMQ Client ID.
client_cert:
type: string
description: Client certificate.
@@ -522,7 +522,7 @@ components:
client_id:
type: string
format: uuid
description: ID of the corresponding Magistrala Client.
description: ID of the corresponding SuperMQ Client.
channels:
type: array
minItems: 0
+5 -5
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala Certs service
title: SuperMQ Certs service
description: |
HTTP API for Certs service
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Certs
externalDocs:
description: Find out more about certs
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/{domainID}/certs:
@@ -171,7 +171,7 @@ components:
client_id:
type: string
format: uuid
description: Corresponding Magistrala Client ID.
description: Corresponding SuperMQ Client ID.
client_cert:
type: string
description: Client Certificate.
+6 -6
View File
@@ -3,16 +3,16 @@
openapi: 3.0.3
info:
title: Magistrala Clients Service
title: SuperMQ Clients Service
description: |
This is the Clients Server based on the OpenAPI 3.0 specification. It is the HTTP API for managing platform clients and channels. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,17 +24,17 @@ tags:
description: Everyclient about your Clients
externalDocs:
description: Find out more about clients
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
- name: Channels
description: Everyclient about your Channels
externalDocs:
description: Find out more about clients channels
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
- name: Policies
description: Access to clients policies
externalDocs:
description: Find out more about clients policies
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/{domainID}clients:
+4 -4
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala http adapter
title: SuperMQ http adapter
description: |
HTTP API for sending messages through communication channels.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Messages
externalDocs:
description: Find out more about messages
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/channels/{id}/messages:
+4 -4
View File
@@ -3,16 +3,16 @@
openapi: 3.0.3
info:
title: Magistrala Invitations Service
title: SuperMQ Invitations Service
description: |
This is the Invitations Server based on the OpenAPI 3.0 specification. It is the HTTP API for managing platform invitations. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Invitations
externalDocs:
description: Find out more about Invitations
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/invitations:
+3 -3
View File
@@ -3,16 +3,16 @@
openapi: 3.0.3
info:
title: Magistrala Journal Log Service
title: SuperMQ Journal Log Service
description: |
This is the Journal Log Server based on the OpenAPI 3.0 specification. It is the HTTP API for viewing journal log history. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@mainflux.com
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/master/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
+4 -4
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala Notifiers service
title: SuperMQ Notifiers service
description: |
HTTP API for Notifiers service.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -26,7 +26,7 @@ tags:
description: Everything about your Notifiers
externalDocs:
description: Find out more about notifiers
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/subscriptions:
+4 -4
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala Provision service
title: SuperMQ Provision service
description: |
HTTP API for Provision service
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstracmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Provision
externalDocs:
description: Find out more about provision
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/{domainID}/mapping:
+4 -4
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala reader service
title: SuperMQ reader service
description: |
HTTP API for reading messages.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -32,7 +32,7 @@ tags:
description: Everything about your Readers
externalDocs:
description: Find out more about readers
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/{domainID}/channels/{chanId}/messages:
+6 -6
View File
@@ -3,16 +3,16 @@
openapi: 3.0.1
info:
title: Magistrala twins service
title: SuperMQ twins service
description: |
HTTP API for managing digital twins and their states.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,7 +24,7 @@ tags:
description: Everything about your Twins
externalDocs:
description: Find out more about twins
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/twins:
@@ -244,7 +244,7 @@ components:
description: Name of the attribute.
channel:
type: string
description: Magistrala channel used by attribute.
description: SuperMQ channel used by attribute.
subtopic:
type: string
description: Subtopic used by attribute.
@@ -278,7 +278,7 @@ components:
properties:
owner:
type: string
description: Email address of Magistrala user that owns twin.
description: Email address of SuperMQ user that owns twin.
id:
type: string
format: uuid
+9 -9
View File
@@ -3,16 +3,16 @@
openapi: 3.0.3
info:
title: Magistrala Users Service
title: SuperMQ Users Service
description: |
This is the Users Server based on the OpenAPI 3.0 specification. It is the HTTP API for managing platform users. You can now help us improve the API whether it's by making changes to the definition itself or to the code.
Some useful links:
- [The Magistrala repository](https://github.com/absmach/magistrala)
- [The SuperMQ repository](https://github.com/absmach/supermq)
contact:
email: info@abstractmachines.fr
license:
name: Apache 2.0
url: https://github.com/absmach/magistrala/blob/main/LICENSE
url: https://github.com/absmach/supermq/blob/main/LICENSE
version: 0.14.0
servers:
@@ -24,12 +24,12 @@ tags:
description: Everything about your Users
externalDocs:
description: Find out more about users
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
- name: Groups
description: Everything about your Groups
externalDocs:
description: Find out more about users groups
url: https://docs.magistrala.abstractmachines.fr/
url: https://docs.supermq.abstractmachines.fr/
paths:
/users:
@@ -1266,7 +1266,7 @@ components:
description: User tags.
email:
type: string
example: "john.doe@magistrala.com"
example: "john.doe@supermq.com"
description: User email for example email address.
credentials:
type: object
@@ -1377,7 +1377,7 @@ components:
description: User's last name.
email:
type: string
example: user@magistrala.com
example: user@supermq.com
description: User's email address.
tags:
type: array
@@ -1542,7 +1542,7 @@ components:
properties:
email:
type: string
example: user@magistrala.com
example: user@supermq.com
description: User email address.
required:
- email
@@ -1659,7 +1659,7 @@ components:
properties:
identity:
type: string
example: user@magistrala.com
example: user@supermq.com
description: User identity - email address.
secret:
type: string
+76 -76
View File
@@ -8,7 +8,7 @@ User service is using Auth service gRPC API to obtain login token or password re
- ID - key ID
- Type - one of the three types described below
- IssuerID - an ID of the Magistrala User who issued the key
- IssuerID - an ID of the SuperMQ User who issued the key
- Subject - user ID for which the key is issued
- IssuedAt - the timestamp when the key is issued
- ExpiresAt - the timestamp after which the key is invalid
@@ -29,7 +29,7 @@ API keys are similar to the User keys. The main difference is that API keys have
Recovery key is the password recovery key. It's short-lived token used for password recovery process.
For in-depth explanation of the aforementioned scenarios, as well as thorough understanding of Magistrala, please check out the [official documentation][doc].
For in-depth explanation of the aforementioned scenarios, as well as thorough understanding of SuperMQ, please check out the [official documentation][doc].
The following actions are supported:
@@ -59,53 +59,53 @@ Domain consists of the following fields:
The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.
| Variable | Description | Default |
| ------------------------------ | ----------------------------------------------------------------------- | ------------------------------- |
| MG_AUTH_LOG_LEVEL | Log level for the Auth service (debug, info, warn, error) | info |
| MG_AUTH_DB_HOST | Database host address | localhost |
| MG_AUTH_DB_PORT | Database host port | 5432 |
| MG_AUTH_DB_USER | Database user | magistrala |
| MG_AUTH_DB_PASSWORD | Database password | magistrala |
| MG_AUTH_DB_NAME | Name of the database used by the service | auth |
| MG_AUTH_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| MG_AUTH_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| MG_AUTH_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| MG_AUTH_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| MG_AUTH_HTTP_HOST | Auth service HTTP host | "" |
| MG_AUTH_HTTP_PORT | Auth service HTTP port | 8189 |
| MG_AUTH_HTTP_SERVER_CERT | Path to the PEM encoded HTTP server certificate file | "" |
| MG_AUTH_HTTP_SERVER_KEY | Path to the PEM encoded HTTP server key file | "" |
| MG_AUTH_GRPC_HOST | Auth service gRPC host | "" |
| MG_AUTH_GRPC_PORT | Auth service gRPC port | 8181 |
| MG_AUTH_GRPC_SERVER_CERT | Path to the PEM encoded gRPC server certificate file | "" |
| MG_AUTH_GRPC_SERVER_KEY | Path to the PEM encoded gRPC server key file | "" |
| MG_AUTH_GRPC_SERVER_CA_CERTS | Path to the PEM encoded gRPC server CA certificate file | "" |
| MG_AUTH_GRPC_CLIENT_CA_CERTS | Path to the PEM encoded gRPC client CA certificate file | "" |
| MG_AUTH_SECRET_KEY | String used for signing tokens | secret |
| MG_AUTH_ACCESS_TOKEN_DURATION | The access token expiration period | 1h |
| MG_AUTH_REFRESH_TOKEN_DURATION | The refresh token expiration period | 24h |
| MG_AUTH_INVITATION_DURATION | The invitation token expiration period | 168h |
| MG_SPICEDB_HOST | SpiceDB host address | localhost |
| MG_SPICEDB_PORT | SpiceDB host port | 50051 |
| MG_SPICEDB_PRE_SHARED_KEY | SpiceDB pre-shared key | 12345678 |
| MG_SPICEDB_SCHEMA_FILE | Path to SpiceDB schema file | ./docker/spicedb/schema.zed |
| MG_JAEGER_URL | Jaeger server URL | <http://jaeger:4318/v1/traces> |
| MG_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| MG_SEND_TELEMETRY | Send telemetry to magistrala call home server | true |
| MG_AUTH_ADAPTER_INSTANCE_ID | Adapter instance ID | "" |
| Variable | Description | Default |
| ------------------------------- | ----------------------------------------------------------------------- | ------------------------------ |
| SMQ_AUTH_LOG_LEVEL | Log level for the Auth service (debug, info, warn, error) | info |
| SMQ_AUTH_DB_HOST | Database host address | localhost |
| SMQ_AUTH_DB_PORT | Database host port | 5432 |
| SMQ_AUTH_DB_USER | Database user | supermq |
| SMQ_AUTH_DB_PASSWORD | Database password | supermq |
| SMQ_AUTH_DB_NAME | Name of the database used by the service | auth |
| SMQ_AUTH_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| SMQ_AUTH_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| SMQ_AUTH_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| SMQ_AUTH_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| SMQ_AUTH_HTTP_HOST | Auth service HTTP host | "" |
| SMQ_AUTH_HTTP_PORT | Auth service HTTP port | 8189 |
| SMQ_AUTH_HTTP_SERVER_CERT | Path to the PEM encoded HTTP server certificate file | "" |
| SMQ_AUTH_HTTP_SERVER_KEY | Path to the PEM encoded HTTP server key file | "" |
| SMQ_AUTH_GRPC_HOST | Auth service gRPC host | "" |
| SMQ_AUTH_GRPC_PORT | Auth service gRPC port | 8181 |
| SMQ_AUTH_GRPC_SERVER_CERT | Path to the PEM encoded gRPC server certificate file | "" |
| SMQ_AUTH_GRPC_SERVER_KEY | Path to the PEM encoded gRPC server key file | "" |
| SMQ_AUTH_GRPC_SERVER_CA_CERTS | Path to the PEM encoded gRPC server CA certificate file | "" |
| SMQ_AUTH_GRPC_CLIENT_CA_CERTS | Path to the PEM encoded gRPC client CA certificate file | "" |
| SMQ_AUTH_SECRET_KEY | String used for signing tokens | secret |
| SMQ_AUTH_ACCESS_TOKEN_DURATION | The access token expiration period | 1h |
| SMQ_AUTH_REFRESH_TOKEN_DURATION | The refresh token expiration period | 24h |
| SMQ_AUTH_INVITATION_DURATION | The invitation token expiration period | 168h |
| SMQ_SPICEDB_HOST | SpiceDB host address | localhost |
| SMQ_SPICEDB_PORT | SpiceDB host port | 50051 |
| SMQ_SPICEDB_PRE_SHARED_KEY | SpiceDB pre-shared key | 12345678 |
| SMQ_SPICEDB_SCHEMA_FILE | Path to SpiceDB schema file | ./docker/spicedb/schema.zed |
| SMQ_JAEGER_URL | Jaeger server URL | <http://jaeger:4318/v1/traces> |
| SMQ_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| SMQ_SEND_TELEMETRY | Send telemetry to supermq call home server | true |
| SMQ_AUTH_ADAPTER_INSTANCE_ID | Adapter instance ID | "" |
## Deployment
The service itself is distributed as Docker container. Check the [`auth`](https://github.com/absmach/magistrala/blob/main/docker/docker-compose.yml) service section in docker-compose file to see how service is deployed.
The service itself is distributed as Docker container. Check the [`auth`](https://github.com/absmach/supermq/blob/main/docker/docker-compose.yml) service section in docker-compose file to see how service is deployed.
Running this service outside of container requires working instance of the postgres database, SpiceDB, and Jaeger server.
To start the service outside of the container, execute the following shell script:
```bash
# download the latest version of the service
git clone https://github.com/absmach/magistrala
git clone https://github.com/absmach/supermq
cd magistrala
cd supermq
# compile the service
make auth
@@ -114,46 +114,46 @@ make auth
make install
# set the environment variables and run the service
MG_AUTH_LOG_LEVEL=info \
MG_AUTH_DB_HOST=localhost \
MG_AUTH_DB_PORT=5432 \
MG_AUTH_DB_USER=magistrala \
MG_AUTH_DB_PASSWORD=magistrala \
MG_AUTH_DB_NAME=auth \
MG_AUTH_DB_SSL_MODE=disable \
MG_AUTH_DB_SSL_CERT="" \
MG_AUTH_DB_SSL_KEY="" \
MG_AUTH_DB_SSL_ROOT_CERT="" \
MG_AUTH_HTTP_HOST=localhost \
MG_AUTH_HTTP_PORT=8189 \
MG_AUTH_HTTP_SERVER_CERT="" \
MG_AUTH_HTTP_SERVER_KEY="" \
MG_AUTH_GRPC_HOST=localhost \
MG_AUTH_GRPC_PORT=8181 \
MG_AUTH_GRPC_SERVER_CERT="" \
MG_AUTH_GRPC_SERVER_KEY="" \
MG_AUTH_GRPC_SERVER_CA_CERTS="" \
MG_AUTH_GRPC_CLIENT_CA_CERTS="" \
MG_AUTH_SECRET_KEY=secret \
MG_AUTH_ACCESS_TOKEN_DURATION=1h \
MG_AUTH_REFRESH_TOKEN_DURATION=24h \
MG_AUTH_INVITATION_DURATION=168h \
MG_SPICEDB_HOST=localhost \
MG_SPICEDB_PORT=50051 \
MG_SPICEDB_PRE_SHARED_KEY=12345678 \
MG_SPICEDB_SCHEMA_FILE=./docker/spicedb/schema.zed \
MG_JAEGER_URL=http://localhost:14268/api/traces \
MG_JAEGER_TRACE_RATIO=1.0 \
MG_SEND_TELEMETRY=true \
MG_AUTH_ADAPTER_INSTANCE_ID="" \
$GOBIN/magistrala-auth
SMQ_AUTH_LOG_LEVEL=info \
SMQ_AUTH_DB_HOST=localhost \
SMQ_AUTH_DB_PORT=5432 \
SMQ_AUTH_DB_USER=supermq \
SMQ_AUTH_DB_PASSWORD=supermq \
SMQ_AUTH_DB_NAME=auth \
SMQ_AUTH_DB_SSL_MODE=disable \
SMQ_AUTH_DB_SSL_CERT="" \
SMQ_AUTH_DB_SSL_KEY="" \
SMQ_AUTH_DB_SSL_ROOT_CERT="" \
SMQ_AUTH_HTTP_HOST=localhost \
SMQ_AUTH_HTTP_PORT=8189 \
SMQ_AUTH_HTTP_SERVER_CERT="" \
SMQ_AUTH_HTTP_SERVER_KEY="" \
SMQ_AUTH_GRPC_HOST=localhost \
SMQ_AUTH_GRPC_PORT=8181 \
SMQ_AUTH_GRPC_SERVER_CERT="" \
SMQ_AUTH_GRPC_SERVER_KEY="" \
SMQ_AUTH_GRPC_SERVER_CA_CERTS="" \
SMQ_AUTH_GRPC_CLIENT_CA_CERTS="" \
SMQ_AUTH_SECRET_KEY=secret \
SMQ_AUTH_ACCESS_TOKEN_DURATION=1h \
SMQ_AUTH_REFRESH_TOKEN_DURATION=24h \
SMQ_AUTH_INVITATION_DURATION=168h \
SMQ_SPICEDB_HOST=localhost \
SMQ_SPICEDB_PORT=50051 \
SMQ_SPICEDB_PRE_SHARED_KEY=12345678 \
SMQ_SPICEDB_SCHEMA_FILE=./docker/spicedb/schema.zed \
SMQ_JAEGER_URL=http://localhost:14268/api/traces \
SMQ_JAEGER_TRACE_RATIO=1.0 \
SMQ_SEND_TELEMETRY=true \
SMQ_AUTH_ADAPTER_INSTANCE_ID="" \
$GOBIN/supermq-auth
```
Setting `MG_AUTH_HTTP_SERVER_CERT` and `MG_AUTH_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `MG_AUTH_GRPC_SERVER_CERT` and `MG_AUTH_GRPC_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key. Setting `MG_AUTH_GRPC_SERVER_CA_CERTS` will enable TLS against the service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs. Setting `MG_AUTH_GRPC_CLIENT_CA_CERTS` will enable TLS against the service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
Setting `SMQ_AUTH_HTTP_SERVER_CERT` and `SMQ_AUTH_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `SMQ_AUTH_GRPC_SERVER_CERT` and `SMQ_AUTH_GRPC_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key. Setting `SMQ_AUTH_GRPC_SERVER_CA_CERTS` will enable TLS against the service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs. Setting `SMQ_AUTH_GRPC_CLIENT_CA_CERTS` will enable TLS against the service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
## Usage
For more information about service capabilities and its usage, please check out the [API documentation](https://docs.api.magistrala.abstractmachines.fr/?urls.primaryName=auth.yml).
For more information about service capabilities and its usage, please check out the [API documentation](https://docs.api.supermq.abstractmachines.fr/?urls.primaryName=auth.yml).
[doc]: https://docs.magistrala.abstractmachines.fr
[doc]: https://docs.supermq.abstractmachines.fr
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"context"
"time"
grpcapi "github.com/absmach/magistrala/auth/api/grpc"
grpcAuthV1 "github.com/absmach/magistrala/internal/grpc/auth/v1"
grpcapi "github.com/absmach/supermq/auth/api/grpc"
grpcAuthV1 "github.com/absmach/supermq/internal/grpc/auth/v1"
"github.com/go-kit/kit/endpoint"
kitgrpc "github.com/go-kit/kit/transport/grpc"
"google.golang.org/grpc"
+2 -2
View File
@@ -6,8 +6,8 @@ package auth
import (
"context"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/policies"
"github.com/go-kit/kit/endpoint"
)
+8 -8
View File
@@ -10,13 +10,13 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
grpcapi "github.com/absmach/magistrala/auth/api/grpc/auth"
grpcAuthV1 "github.com/absmach/magistrala/internal/grpc/auth/v1"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/auth"
grpcapi "github.com/absmach/supermq/auth/api/grpc/auth"
grpcAuthV1 "github.com/absmach/supermq/internal/grpc/auth/v1"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"
@@ -31,7 +31,7 @@ const (
clientsType = "clients"
usersType = "users"
description = "Description"
groupName = "mgx"
groupName = "smqx"
adminpermission = "admin"
authoritiesObj = "authorities"
+1 -1
View File
@@ -4,7 +4,7 @@
package auth
import (
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/pkg/apiutil"
)
type authenticateReq struct {
+3 -3
View File
@@ -6,9 +6,9 @@ package auth
import (
"context"
"github.com/absmach/magistrala/auth"
grpcapi "github.com/absmach/magistrala/auth/api/grpc"
grpcAuthV1 "github.com/absmach/magistrala/internal/grpc/auth/v1"
"github.com/absmach/supermq/auth"
grpcapi "github.com/absmach/supermq/auth/api/grpc"
grpcAuthV1 "github.com/absmach/supermq/internal/grpc/auth/v1"
kitgrpc "github.com/go-kit/kit/transport/grpc"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"os"
"testing"
"github.com/absmach/magistrala/auth/mocks"
"github.com/absmach/supermq/auth/mocks"
)
var svc *mocks.Service
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"context"
"time"
"github.com/absmach/magistrala/auth"
grpcapi "github.com/absmach/magistrala/auth/api/grpc"
grpcTokenV1 "github.com/absmach/magistrala/internal/grpc/token/v1"
"github.com/absmach/supermq/auth"
grpcapi "github.com/absmach/supermq/auth/api/grpc"
grpcTokenV1 "github.com/absmach/supermq/internal/grpc/token/v1"
"github.com/go-kit/kit/endpoint"
kitgrpc "github.com/go-kit/kit/transport/grpc"
"google.golang.org/grpc"
+1 -1
View File
@@ -6,7 +6,7 @@ package token
import (
"context"
"github.com/absmach/magistrala/auth"
"github.com/absmach/supermq/auth"
"github.com/go-kit/kit/endpoint"
)
+8 -8
View File
@@ -10,13 +10,13 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
grpcapi "github.com/absmach/magistrala/auth/api/grpc/token"
grpcTokenV1 "github.com/absmach/magistrala/internal/grpc/token/v1"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/auth"
grpcapi "github.com/absmach/supermq/auth/api/grpc/token"
grpcTokenV1 "github.com/absmach/supermq/internal/grpc/token/v1"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"google.golang.org/grpc"
@@ -31,7 +31,7 @@ const (
clientsType = "clients"
usersType = "users"
description = "Description"
groupName = "mgx"
groupName = "smqx"
adminpermission = "admin"
authoritiesObj = "authorities"
+2 -2
View File
@@ -4,8 +4,8 @@
package token
import (
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/apiutil"
)
type issueReq struct {
+3 -3
View File
@@ -6,9 +6,9 @@ package token
import (
"context"
"github.com/absmach/magistrala/auth"
grpcapi "github.com/absmach/magistrala/auth/api/grpc"
grpcTokenV1 "github.com/absmach/magistrala/internal/grpc/token/v1"
"github.com/absmach/supermq/auth"
grpcapi "github.com/absmach/supermq/auth/api/grpc"
grpcTokenV1 "github.com/absmach/supermq/internal/grpc/token/v1"
kitgrpc "github.com/go-kit/kit/transport/grpc"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"os"
"testing"
"github.com/absmach/magistrala/auth/mocks"
"github.com/absmach/supermq/auth/mocks"
)
var svc *mocks.Service
+4 -4
View File
@@ -6,10 +6,10 @@ package grpc
import (
"fmt"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"context"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/supermq/auth"
"github.com/go-kit/kit/endpoint"
)
+10 -10
View File
@@ -14,15 +14,15 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
httpapi "github.com/absmach/magistrala/auth/api/http"
"github.com/absmach/magistrala/auth/jwt"
"github.com/absmach/magistrala/auth/mocks"
mglog "github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/apiutil"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
policymocks "github.com/absmach/magistrala/pkg/policies/mocks"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/absmach/supermq/auth"
httpapi "github.com/absmach/supermq/auth/api/http"
"github.com/absmach/supermq/auth/jwt"
"github.com/absmach/supermq/auth/mocks"
smqlog "github.com/absmach/supermq/logger"
"github.com/absmach/supermq/pkg/apiutil"
svcerr "github.com/absmach/supermq/pkg/errors/service"
policymocks "github.com/absmach/supermq/pkg/policies/mocks"
"github.com/absmach/supermq/pkg/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -78,7 +78,7 @@ func newService() (auth.Service, *mocks.KeyRepository) {
}
func newServer(svc auth.Service) *httptest.Server {
mux := httpapi.MakeHandler(svc, mglog.NewMock(), "")
mux := httpapi.MakeHandler(svc, smqlog.NewMock(), "")
return httptest.NewServer(mux)
}
+2 -2
View File
@@ -6,8 +6,8 @@ package keys
import (
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/apiutil"
)
type issueKeyReq struct {
+2 -2
View File
@@ -6,8 +6,8 @@ package keys
import (
"testing"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/stretchr/testify/assert"
)
+4 -4
View File
@@ -7,13 +7,13 @@ import (
"net/http"
"time"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/auth"
"github.com/absmach/supermq"
"github.com/absmach/supermq/auth"
)
var (
_ magistrala.Response = (*issueKeyRes)(nil)
_ magistrala.Response = (*revokeKeyRes)(nil)
_ supermq.Response = (*issueKeyRes)(nil)
_ supermq.Response = (*revokeKeyRes)(nil)
)
type issueKeyRes struct {
+4 -4
View File
@@ -10,10 +10,10 @@ import (
"net/http"
"strings"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/internal/api"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/errors"
"github.com/go-chi/chi/v5"
kithttp "github.com/go-kit/kit/transport/http"
)
+4 -4
View File
@@ -6,9 +6,9 @@ import (
"log/slog"
"net/http"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/auth/api/http/keys"
"github.com/absmach/supermq"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/auth/api/http/keys"
"github.com/go-chi/chi/v5"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
@@ -19,7 +19,7 @@ func MakeHandler(svc auth.Service, logger *slog.Logger, instanceID string) http.
mux = keys.MakeHandler(svc, mux, logger)
mux.Get("/health", magistrala.Health("auth", instanceID))
mux.Get("/health", supermq.Health("auth", instanceID))
mux.Handle("/metrics", promhttp.Handler())
return mux
+2 -2
View File
@@ -10,8 +10,8 @@ import (
"log/slog"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/policies"
)
var _ auth.Service = (*loggingMiddleware)(nil)
+2 -2
View File
@@ -9,8 +9,8 @@ import (
"context"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/policies"
"github.com/go-kit/kit/metrics"
)
+7 -7
View File
@@ -8,11 +8,11 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
authjwt "github.com/absmach/magistrala/auth/jwt"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/auth"
authjwt "github.com/absmach/supermq/auth/jwt"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwt"
"github.com/stretchr/testify/assert"
@@ -23,7 +23,7 @@ const (
tokenType = "type"
userField = "user"
domainField = "domain"
issuerName = "magistrala.auth"
issuerName = "supermq.auth"
secret = "test"
)
@@ -242,7 +242,7 @@ func key() auth.Key {
return auth.Key{
ID: "66af4a67-3823-438a-abd7-efdb613eaef6",
Type: auth.AccessKey,
Issuer: "magistrala.auth",
Issuer: "supermq.auth",
Subject: "66af4a67-3823-438a-abd7-efdb613eaef6",
IssuedAt: time.Now().UTC().Add(-10 * time.Second).Round(time.Second),
ExpiresAt: exp,
+4 -4
View File
@@ -9,9 +9,9 @@ import (
"fmt"
"strconv"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/lestrrat-go/jwx/v2/jwa"
"github.com/lestrrat-go/jwx/v2/jwt"
)
@@ -29,7 +29,7 @@ var (
)
const (
issuerName = "magistrala.auth"
issuerName = "supermq.auth"
tokenType = "type"
userField = "user"
oauthProviderField = "oauth_provider"
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/supermq/auth"
"github.com/stretchr/testify/assert"
)
+1 -1
View File
@@ -7,7 +7,7 @@ package mocks
import (
context "context"
policies "github.com/absmach/magistrala/pkg/policies"
policies "github.com/absmach/supermq/pkg/policies"
mock "github.com/stretchr/testify/mock"
)
+1 -1
View File
@@ -7,7 +7,7 @@ package mocks
import (
context "context"
auth "github.com/absmach/magistrala/auth"
auth "github.com/absmach/supermq/auth"
mock "github.com/stretchr/testify/mock"
)
+2 -2
View File
@@ -7,11 +7,11 @@ package mocks
import (
context "context"
auth "github.com/absmach/magistrala/auth"
auth "github.com/absmach/supermq/auth"
mock "github.com/stretchr/testify/mock"
policies "github.com/absmach/magistrala/pkg/policies"
policies "github.com/absmach/supermq/pkg/policies"
)
// Service is an autogenerated mock type for the Service type
+1 -1
View File
@@ -13,7 +13,7 @@ import (
mock "github.com/stretchr/testify/mock"
v1 "github.com/absmach/magistrala/internal/grpc/token/v1"
v1 "github.com/absmach/supermq/internal/grpc/token/v1"
)
// TokenServiceClient is an autogenerated mock type for the TokenServiceClient type
+4 -4
View File
@@ -8,10 +8,10 @@ import (
"database/sql"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
"github.com/absmach/magistrala/pkg/postgres"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
"github.com/absmach/supermq/pkg/postgres"
)
var (
+5 -5
View File
@@ -10,11 +10,11 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/auth/postgres"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/auth/postgres"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
"github.com/absmach/supermq/pkg/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
+3 -3
View File
@@ -13,9 +13,9 @@ import (
"testing"
"time"
apostgres "github.com/absmach/magistrala/auth/postgres"
"github.com/absmach/magistrala/pkg/postgres"
pgclient "github.com/absmach/magistrala/pkg/postgres"
apostgres "github.com/absmach/supermq/auth/postgres"
"github.com/absmach/supermq/pkg/postgres"
pgclient "github.com/absmach/supermq/pkg/postgres"
"github.com/jmoiron/sqlx"
dockertest "github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
+8 -8
View File
@@ -8,10 +8,10 @@ import (
"strings"
"time"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/absmach/supermq/pkg/policies"
)
const (
@@ -81,7 +81,7 @@ var _ Service = (*service)(nil)
type service struct {
keys KeyRepository
idProvider magistrala.IDProvider
idProvider supermq.IDProvider
evaluator policies.Evaluator
policysvc policies.Service
tokenizer Tokenizer
@@ -91,7 +91,7 @@ type service struct {
}
// New instantiates the auth service implementation.
func New(keys KeyRepository, idp magistrala.IDProvider, tokenizer Tokenizer, policyEvaluator policies.Evaluator, policyService policies.Service, loginDuration, refreshDuration, invitationDuration time.Duration) Service {
func New(keys KeyRepository, idp supermq.IDProvider, tokenizer Tokenizer, policyEvaluator policies.Evaluator, policyService policies.Service, loginDuration, refreshDuration, invitationDuration time.Duration) Service {
return &service{
tokenizer: tokenizer,
keys: keys,
@@ -227,7 +227,7 @@ func (svc service) checkDomain(ctx context.Context, subjectType, subject, domain
}
func (svc service) PolicyValidation(pr policies.Policy) error {
if pr.ObjectType == policies.PlatformType && pr.Object != policies.MagistralaObject {
if pr.ObjectType == policies.PlatformType && pr.Object != policies.SuperMQObject {
return errPlatform
}
return nil
@@ -329,7 +329,7 @@ func (svc service) checkUserDomain(ctx context.Context, key Key) (subject string
Subject: key.User,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
}); err == nil {
return key.User, nil
+37 -37
View File
@@ -9,16 +9,16 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/auth/jwt"
"github.com/absmach/magistrala/auth/mocks"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/policies"
policymocks "github.com/absmach/magistrala/pkg/policies/mocks"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/auth/jwt"
"github.com/absmach/supermq/auth/mocks"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/absmach/supermq/pkg/policies"
policymocks "github.com/absmach/supermq/pkg/policies/mocks"
"github.com/absmach/supermq/pkg/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -27,7 +27,7 @@ const (
secret = "secret"
email = "test@example.com"
id = "testID"
groupName = "mgx"
groupName = "smqx"
description = "Description"
memberRelation = "member"
authoritiesObj = "authorities"
@@ -142,7 +142,7 @@ func TestIssue(t *testing.T) {
},
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -163,7 +163,7 @@ func TestIssue(t *testing.T) {
},
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -185,7 +185,7 @@ func TestIssue(t *testing.T) {
token: accessToken,
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -208,7 +208,7 @@ func TestIssue(t *testing.T) {
token: accessToken,
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -237,7 +237,7 @@ func TestIssue(t *testing.T) {
token: accessToken,
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -266,7 +266,7 @@ func TestIssue(t *testing.T) {
token: accessToken,
checkPolicyRequest: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -375,7 +375,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{},
@@ -394,7 +394,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkPlatformAdminErr: nil,
@@ -413,7 +413,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{
@@ -447,7 +447,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{
@@ -473,7 +473,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{},
@@ -491,7 +491,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{},
@@ -506,7 +506,7 @@ func TestIssue(t *testing.T) {
checkPlatformAdminReq: policies.Policy{
Subject: email,
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -525,7 +525,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkPlatformAdminErr: nil,
@@ -544,7 +544,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{
@@ -578,7 +578,7 @@ func TestIssue(t *testing.T) {
Subject: userID,
SubjectType: policies.UserType,
Permission: policies.AdminPermission,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
},
checkDomainMemberReq: policies.Policy{
@@ -885,7 +885,7 @@ func TestAuthorize(t *testing.T) {
Subject: accessToken,
SubjectType: policies.UserType,
SubjectKind: policies.TokenKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -893,7 +893,7 @@ func TestAuthorize(t *testing.T) {
Subject: id,
SubjectType: policies.UserType,
SubjectKind: policies.TokenKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -970,7 +970,7 @@ func TestAuthorize(t *testing.T) {
Subject: expSecret.AccessToken,
SubjectType: policies.UserType,
SubjectKind: policies.TokenKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -1010,13 +1010,13 @@ func TestAuthorize(t *testing.T) {
Subject: emptySubject.AccessToken,
SubjectType: policies.UserType,
SubjectKind: policies.TokenKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.DomainType,
Permission: policies.AdminPermission,
},
checkPolicyReq: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformKind,
Permission: policies.AdminPermission,
},
@@ -1041,7 +1041,7 @@ func TestAuthorize(t *testing.T) {
},
checkPolicyReq: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -1059,14 +1059,14 @@ func TestAuthorize(t *testing.T) {
policyReq: policies.Policy{
SubjectType: policies.UserType,
SubjectKind: policies.UsersKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
checkPolicyReq: policies.Policy{
SubjectType: policies.UserType,
SubjectKind: policies.UsersKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
@@ -1085,13 +1085,13 @@ func TestAuthorize(t *testing.T) {
Subject: emptySubject.AccessToken,
SubjectType: policies.UserType,
SubjectKind: policies.TokenKind,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.DomainType,
Permission: policies.AdminPermission,
},
checkPolicyReq: policies.Policy{
SubjectType: policies.UserType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
ObjectType: policies.PlatformType,
Permission: policies.AdminPermission,
},
+5 -5
View File
@@ -1,12 +1,12 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
// Package tracing provides tracing instrumentation for Magistrala Users service.
// Package tracing provides tracing instrumentation for SuperMQ Users service.
//
// This package provides tracing middleware for Magistrala Users service.
// This package provides tracing middleware for SuperMQ Users service.
// It can be used to trace incoming requests and add tracing capabilities to
// Magistrala Users service.
// SuperMQ Users service.
//
// For more details about tracing instrumentation for Magistrala messaging refer
// to the documentation at https://docs.magistrala.abstractmachines.fr/tracing/.
// For more details about tracing instrumentation for SuperMQ messaging refer
// to the documentation at https://docs.supermq.abstractmachines.fr/tracing/.
package tracing
+2 -2
View File
@@ -7,8 +7,8 @@ import (
"context"
"fmt"
"github.com/absmach/magistrala/auth"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq/auth"
"github.com/absmach/supermq/pkg/policies"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
+59 -59
View File
@@ -22,8 +22,8 @@ Client Configuration consists of two logical parts: the custom configuration tha
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 |
| -------- | --------------------------------------------- |
| State | What it means |
| -------- | ---------------------------------------------- |
| Inactive | Client is created, but isn't enabled |
| Active | Client is able to communicate using Magistrala |
@@ -35,35 +35,35 @@ Client configuration also contains the so-called `external ID` and `external key
The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.
| Variable | Description | Default |
| ----------------------------- | -------------------------------------------------------------------------------- | --------------------------------- |
| MG_BOOTSTRAP_LOG_LEVEL | Log level for Bootstrap (debug, info, warn, error) | info |
| MG_BOOTSTRAP_DB_HOST | Database host address | localhost |
| MG_BOOTSTRAP_DB_PORT | Database host port | 5432 |
| MG_BOOTSTRAP_DB_USER | Database user | magistrala |
| MG_BOOTSTRAP_DB_PASS | Database password | magistrala |
| MG_BOOTSTRAP_DB_NAME | Name of the database used by the service | bootstrap |
| MG_BOOTSTRAP_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| MG_BOOTSTRAP_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| MG_BOOTSTRAP_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| MG_BOOTSTRAP_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| MG_BOOTSTRAP_ENCRYPT_KEY | Secret key for secure bootstrapping encryption | 12345678910111213141516171819202 |
| MG_BOOTSTRAP_HTTP_HOST | Bootstrap service HTTP host | "" |
| MG_BOOTSTRAP_HTTP_PORT | Bootstrap service HTTP port | 9013 |
| MG_BOOTSTRAP_HTTP_SERVER_CERT | Path to server certificate in pem format | "" |
| MG_BOOTSTRAP_HTTP_SERVER_KEY | Path to server key in pem format | "" |
| MG_BOOTSTRAP_EVENT_CONSUMER | Bootstrap service event source consumer name | bootstrap |
| MG_ES_URL | Event store URL | <nats://localhost:4222> |
| MG_AUTH_GRPC_URL | Auth service Auth gRPC URL | <localhost:8181> |
| MG_AUTH_GRPC_TIMEOUT | Auth service Auth gRPC request timeout in seconds | 1s |
| MG_AUTH_GRPC_CLIENT_CERT | Path to the PEM encoded auth service Auth gRPC client certificate file | "" |
| MG_AUTH_GRPC_CLIENT_KEY | Path to the PEM encoded auth service Auth gRPC client key file | "" |
| MG_AUTH_GRPC_SERVER_CERTS | Path to the PEM encoded auth server Auth gRPC server trusted CA certificate file | "" |
| MG_CLIENTS_URL | Base URL for Magistrala Clients | <http://localhost:9000> |
| MG_JAEGER_URL | Jaeger server URL | <http://localhost:4318/v1/traces> |
| MG_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| MG_SEND_TELEMETRY | Send telemetry to magistrala call home server | true |
| MG_BOOTSTRAP_INSTANCE_ID | Bootstrap service instance ID | "" |
| Variable | Description | Default |
| ------------------------------ | -------------------------------------------------------------------------------- | --------------------------------- |
| SMQ_BOOTSTRAP_LOG_LEVEL | Log level for Bootstrap (debug, info, warn, error) | info |
| SMQ_BOOTSTRAP_DB_HOST | Database host address | localhost |
| SMQ_BOOTSTRAP_DB_PORT | Database host port | 5432 |
| SMQ_BOOTSTRAP_DB_USER | Database user | magistrala |
| SMQ_BOOTSTRAP_DB_PASS | Database password | magistrala |
| SMQ_BOOTSTRAP_DB_NAME | Name of the database used by the service | bootstrap |
| SMQ_BOOTSTRAP_DB_SSL_MODE | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| SMQ_BOOTSTRAP_DB_SSL_CERT | Path to the PEM encoded certificate file | "" |
| SMQ_BOOTSTRAP_DB_SSL_KEY | Path to the PEM encoded key file | "" |
| SMQ_BOOTSTRAP_DB_SSL_ROOT_CERT | Path to the PEM encoded root certificate file | "" |
| SMQ_BOOTSTRAP_ENCRYPT_KEY | Secret key for secure bootstrapping encryption | 12345678910111213141516171819202 |
| SMQ_BOOTSTRAP_HTTP_HOST | Bootstrap service HTTP host | "" |
| SMQ_BOOTSTRAP_HTTP_PORT | Bootstrap service HTTP port | 9013 |
| SMQ_BOOTSTRAP_HTTP_SERVER_CERT | Path to server certificate in pem format | "" |
| SMQ_BOOTSTRAP_HTTP_SERVER_KEY | Path to server key in pem format | "" |
| SMQ_BOOTSTRAP_EVENT_CONSUMER | Bootstrap service event source consumer name | bootstrap |
| SMQ_ES_URL | Event store URL | <nats://localhost:4222> |
| SMQ_AUTH_GRPC_URL | Auth service Auth gRPC URL | <localhost:8181> |
| SMQ_AUTH_GRPC_TIMEOUT | Auth service Auth gRPC request timeout in seconds | 1s |
| SMQ_AUTH_GRPC_CLIENT_CERT | Path to the PEM encoded auth service Auth gRPC client certificate file | "" |
| SMQ_AUTH_GRPC_CLIENT_KEY | Path to the PEM encoded auth service Auth gRPC client key file | "" |
| SMQ_AUTH_GRPC_SERVER_CERTS | Path to the PEM encoded auth server Auth gRPC server trusted CA certificate file | "" |
| SMQ_CLIENTS_URL | Base URL for Magistrala Clients | <http://localhost:9000> |
| SMQ_JAEGER_URL | Jaeger server URL | <http://localhost:4318/v1/traces> |
| SMQ_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| SMQ_SEND_TELEMETRY | Send telemetry to magistrala call home server | true |
| SMQ_BOOTSTRAP_INSTANCE_ID | Bootstrap service instance ID | "" |
## Deployment
@@ -84,38 +84,38 @@ make bootstrap
make install
# set the environment variables and run the service
MG_BOOTSTRAP_LOG_LEVEL=info \
MG_BOOTSTRAP_DB_HOST=localhost \
MG_BOOTSTRAP_DB_PORT=5432 \
MG_BOOTSTRAP_DB_USER=magistrala \
MG_BOOTSTRAP_DB_PASS=magistrala \
MG_BOOTSTRAP_DB_NAME=bootstrap \
MG_BOOTSTRAP_DB_SSL_MODE=disable \
MG_BOOTSTRAP_DB_SSL_CERT="" \
MG_BOOTSTRAP_DB_SSL_KEY="" \
MG_BOOTSTRAP_DB_SSL_ROOT_CERT="" \
MG_BOOTSTRAP_HTTP_HOST=localhost \
MG_BOOTSTRAP_HTTP_PORT=9013 \
MG_BOOTSTRAP_HTTP_SERVER_CERT="" \
MG_BOOTSTRAP_HTTP_SERVER_KEY="" \
MG_BOOTSTRAP_EVENT_CONSUMER=bootstrap \
MG_ES_URL=nats://localhost:4222 \
MG_AUTH_GRPC_URL=localhost:8181 \
MG_AUTH_GRPC_TIMEOUT=1s \
MG_AUTH_GRPC_CLIENT_CERT="" \
MG_AUTH_GRPC_CLIENT_KEY="" \
MG_AUTH_GRPC_SERVER_CERTS="" \
MG_CLIENTS_URL=http://localhost:9000 \
MG_JAEGER_URL=http://localhost:14268/api/traces \
MG_JAEGER_TRACE_RATIO=1.0 \
MG_SEND_TELEMETRY=true \
MG_BOOTSTRAP_INSTANCE_ID="" \
SMQ_BOOTSTRAP_LOG_LEVEL=info \
SMQ_BOOTSTRAP_DB_HOST=localhost \
SMQ_BOOTSTRAP_DB_PORT=5432 \
SMQ_BOOTSTRAP_DB_USER=magistrala \
SMQ_BOOTSTRAP_DB_PASS=magistrala \
SMQ_BOOTSTRAP_DB_NAME=bootstrap \
SMQ_BOOTSTRAP_DB_SSL_MODE=disable \
SMQ_BOOTSTRAP_DB_SSL_CERT="" \
SMQ_BOOTSTRAP_DB_SSL_KEY="" \
SMQ_BOOTSTRAP_DB_SSL_ROOT_CERT="" \
SMQ_BOOTSTRAP_HTTP_HOST=localhost \
SMQ_BOOTSTRAP_HTTP_PORT=9013 \
SMQ_BOOTSTRAP_HTTP_SERVER_CERT="" \
SMQ_BOOTSTRAP_HTTP_SERVER_KEY="" \
SMQ_BOOTSTRAP_EVENT_CONSUMER=bootstrap \
SMQ_ES_URL=nats://localhost:4222 \
SMQ_AUTH_GRPC_URL=localhost:8181 \
SMQ_AUTH_GRPC_TIMEOUT=1s \
SMQ_AUTH_GRPC_CLIENT_CERT="" \
SMQ_AUTH_GRPC_CLIENT_KEY="" \
SMQ_AUTH_GRPC_SERVER_CERTS="" \
SMQ_CLIENTS_URL=http://localhost:9000 \
SMQ_JAEGER_URL=http://localhost:14268/api/traces \
SMQ_JAEGER_TRACE_RATIO=1.0 \
SMQ_SEND_TELEMETRY=true \
SMQ_BOOTSTRAP_INSTANCE_ID="" \
$GOBIN/magistrala-bootstrap
```
Setting `MG_BOOTSTRAP_HTTP_SERVER_CERT` and `MG_BOOTSTRAP_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `SMQ_BOOTSTRAP_HTTP_SERVER_CERT` and `SMQ_BOOTSTRAP_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `MG_AUTH_GRPC_CLIENT_CERT` and `MG_AUTH_GRPC_CLIENT_KEY` will enable TLS against the auth service. The service expects a file in PEM format for both the certificate and the key. Setting `MG_AUTH_GRPC_SERVER_CERTS` will enable TLS against the auth service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
Setting `SMQ_AUTH_GRPC_CLIENT_CERT` and `SMQ_AUTH_GRPC_CLIENT_KEY` will enable TLS against the auth service. The service expects a file in PEM format for both the certificate and the key. Setting `SMQ_AUTH_GRPC_SERVER_CERTS` will enable TLS against the auth service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
## Usage
+6 -6
View File
@@ -6,12 +6,12 @@ package api
import (
"context"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/internal/api"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/go-kit/kit/endpoint"
)
+28 -28
View File
@@ -18,16 +18,16 @@ import (
"strings"
"testing"
"github.com/absmach/magistrala/bootstrap"
bsapi "github.com/absmach/magistrala/bootstrap/api"
"github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
mglog "github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/apiutil"
mgauthn "github.com/absmach/magistrala/pkg/authn"
authnmocks "github.com/absmach/magistrala/pkg/authn/mocks"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/bootstrap"
bsapi "github.com/absmach/supermq/bootstrap/api"
"github.com/absmach/supermq/bootstrap/mocks"
"github.com/absmach/supermq/internal/testsutil"
smqlog "github.com/absmach/supermq/logger"
"github.com/absmach/supermq/pkg/apiutil"
smqauthn "github.com/absmach/supermq/pkg/authn"
authnmocks "github.com/absmach/supermq/pkg/authn/mocks"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -177,7 +177,7 @@ func dec(in []byte) ([]byte, error) {
}
func newBootstrapServer() (*httptest.Server, *mocks.Service, *authnmocks.Authentication) {
logger := mglog.NewMock()
logger := smqlog.NewMock()
svc := new(mocks.Service)
authn := new(authnmocks.Authentication)
mux := bsapi.MakeHandler(svc, authn, bootstrap.NewConfigReader(encKey), logger, instanceID)
@@ -212,7 +212,7 @@ func TestAdd(t *testing.T) {
req string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
contentType string
status int
location string
@@ -324,7 +324,7 @@ func TestAdd(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
@@ -372,7 +372,7 @@ func TestView(t *testing.T) {
cases := []struct {
desc string
token string
session mgauthn.Session
session smqauthn.Session
id string
status int
res config
@@ -425,7 +425,7 @@ func TestView(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("View", mock.Anything, tc.session, tc.id).Return(c, tc.err)
@@ -467,7 +467,7 @@ func TestUpdate(t *testing.T) {
req string
id string
token string
session mgauthn.Session
session smqauthn.Session
contentType string
status int
authenticateErr error
@@ -542,7 +542,7 @@ func TestUpdate(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("Update", mock.Anything, tc.session, mock.Anything).Return(tc.err)
@@ -575,7 +575,7 @@ func TestUpdateCert(t *testing.T) {
req string
id string
token string
session mgauthn.Session
session smqauthn.Session
contentType string
status int
authenticateErr error
@@ -650,7 +650,7 @@ func TestUpdateCert(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("UpdateCert", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(c, tc.err)
@@ -687,7 +687,7 @@ func TestUpdateConnections(t *testing.T) {
req string
id string
token string
session mgauthn.Session
session smqauthn.Session
contentType string
status int
authenticateErr error
@@ -771,7 +771,7 @@ func TestUpdateConnections(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
repoCall := svc.On("UpdateConnections", mock.Anything, tc.session, tc.token, mock.Anything, mock.Anything).Return(tc.err)
@@ -833,7 +833,7 @@ func TestList(t *testing.T) {
state = bootstrap.Inactive
}
svcCall := svc.On("ChangeState", context.Background(), mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(nil)
err := svc.ChangeState(context.Background(), mgauthn.Session{}, validToken, list[i].ClientID, state)
err := svc.ChangeState(context.Background(), smqauthn.Session{}, validToken, list[i].ClientID, state)
assert.Nil(t, err, fmt.Sprintf("Changing state expected to succeed: %s.\n", err))
svcCall.Unset()
@@ -849,7 +849,7 @@ func TestList(t *testing.T) {
cases := []struct {
desc string
token string
session mgauthn.Session
session smqauthn.Session
url string
status int
res configPage
@@ -1040,7 +1040,7 @@ func TestList(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("List", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(bootstrap.ConfigsPage{Total: tc.res.Total, Offset: tc.res.Offset, Limit: tc.res.Limit}, tc.err)
@@ -1077,7 +1077,7 @@ func TestRemove(t *testing.T) {
desc string
id string
token string
session mgauthn.Session
session smqauthn.Session
status int
authenticateErr error
err error
@@ -1123,7 +1123,7 @@ func TestRemove(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("Remove", mock.Anything, mock.Anything, mock.Anything).Return(tc.err)
@@ -1287,7 +1287,7 @@ func TestChangeState(t *testing.T) {
desc string
id string
token string
session mgauthn.Session
session smqauthn.Session
state string
contentType string
status int
@@ -1372,7 +1372,7 @@ func TestChangeState(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
if tc.token == validToken {
tc.session = mgauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
tc.session = smqauthn.Session{DomainUserID: domainID + "_" + validID, UserID: validID, DomainID: domainID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("ChangeState", mock.Anything, tc.session, tc.token, mock.Anything, mock.Anything).Return(tc.err)
+2 -2
View File
@@ -4,8 +4,8 @@
package api
import (
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/pkg/apiutil"
)
const maxLimitSize = 100
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"fmt"
"testing"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/stretchr/testify/assert"
)
+7 -7
View File
@@ -7,16 +7,16 @@ import (
"fmt"
"net/http"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/supermq"
"github.com/absmach/supermq/bootstrap"
)
var (
_ magistrala.Response = (*removeRes)(nil)
_ magistrala.Response = (*configRes)(nil)
_ magistrala.Response = (*stateRes)(nil)
_ magistrala.Response = (*viewRes)(nil)
_ magistrala.Response = (*listRes)(nil)
_ supermq.Response = (*removeRes)(nil)
_ supermq.Response = (*configRes)(nil)
_ supermq.Response = (*stateRes)(nil)
_ supermq.Response = (*viewRes)(nil)
_ supermq.Response = (*listRes)(nil)
)
type removeRes struct{}
+8 -8
View File
@@ -11,12 +11,12 @@ import (
"net/url"
"strings"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/internal/api"
"github.com/absmach/magistrala/pkg/apiutil"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/supermq"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/internal/api"
"github.com/absmach/supermq/pkg/apiutil"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
"github.com/go-chi/chi/v5"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -40,7 +40,7 @@ var (
)
// MakeHandler returns a HTTP handler for API endpoints.
func MakeHandler(svc bootstrap.Service, authn mgauthn.Authentication, reader bootstrap.ConfigReader, logger *slog.Logger, instanceID string) http.Handler {
func MakeHandler(svc bootstrap.Service, authn smqauthn.Authentication, reader bootstrap.ConfigReader, logger *slog.Logger, instanceID string) http.Handler {
opts := []kithttp.ServerOption{
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
}
@@ -121,7 +121,7 @@ func MakeHandler(svc bootstrap.Service, authn mgauthn.Authentication, reader boo
opts...), "bootstrap_secure").ServeHTTP)
})
r.Get("/health", magistrala.Health("bootstrap", instanceID))
r.Get("/health", supermq.Health("bootstrap", instanceID))
r.Handle("/metrics", promhttp.Handler())
return r
+6 -6
View File
@@ -7,14 +7,14 @@ import (
"context"
"time"
"github.com/absmach/magistrala/clients"
"github.com/absmach/supermq/clients"
)
// Config represents Configuration entity. It wraps information about external entity
// as well as info about corresponding Magistrala entities.
// MGClient represents corresponding Magistrala Client ID.
// MGKey is key of corresponding Magistrala Client.
// MGChannels is a list of Magistrala Channels corresponding Magistrala Client connects to.
// as well as info about corresponding SuperMQ entities.
// MGClient represents corresponding SuperMQ Client ID.
// MGKey is key of corresponding SuperMQ Client.
// MGChannels is a list of SuperMQ Channels corresponding SuperMQ Client connects to.
type Config struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
@@ -30,7 +30,7 @@ type Config struct {
State State `json:"state"`
}
// Channel represents Magistrala channel corresponding Magistrala Client is connected to.
// Channel represents SuperMQ channel corresponding SuperMQ Client is connected to.
type Channel struct {
ID string `json:"id"`
Name string `json:"name,omitempty"`
+1 -1
View File
@@ -2,5 +2,5 @@
// SPDX-License-Identifier: Apache-2.0
// Package bootstrap contains the domain concept definitions needed to support
// Magistrala bootstrap service functionality.
// SuperMQ bootstrap service functionality.
package bootstrap
+3 -3
View File
@@ -7,9 +7,9 @@ import (
"context"
"time"
"github.com/absmach/magistrala/bootstrap"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/events"
"github.com/absmach/supermq/bootstrap"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/absmach/supermq/pkg/events"
)
const (
+2 -2
View File
@@ -4,8 +4,8 @@
package producer
import (
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/pkg/events"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/pkg/events"
)
const (
+11 -11
View File
@@ -6,9 +6,9 @@ package producer
import (
"context"
"github.com/absmach/magistrala/bootstrap"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/events"
"github.com/absmach/supermq/bootstrap"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/events"
)
var _ bootstrap.Service = (*eventStore)(nil)
@@ -27,7 +27,7 @@ func NewEventStoreMiddleware(svc bootstrap.Service, publisher events.Publisher)
}
}
func (es *eventStore) Add(ctx context.Context, session mgauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
func (es *eventStore) Add(ctx context.Context, session smqauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
saved, err := es.svc.Add(ctx, session, token, cfg)
if err != nil {
return saved, err
@@ -44,7 +44,7 @@ func (es *eventStore) Add(ctx context.Context, session mgauthn.Session, token st
return saved, err
}
func (es *eventStore) View(ctx context.Context, session mgauthn.Session, id string) (bootstrap.Config, error) {
func (es *eventStore) View(ctx context.Context, session smqauthn.Session, id string) (bootstrap.Config, error) {
cfg, err := es.svc.View(ctx, session, id)
if err != nil {
return cfg, err
@@ -60,7 +60,7 @@ func (es *eventStore) View(ctx context.Context, session mgauthn.Session, id stri
return cfg, err
}
func (es *eventStore) Update(ctx context.Context, session mgauthn.Session, cfg bootstrap.Config) error {
func (es *eventStore) Update(ctx context.Context, session smqauthn.Session, cfg bootstrap.Config) error {
if err := es.svc.Update(ctx, session, cfg); err != nil {
return err
}
@@ -72,7 +72,7 @@ func (es *eventStore) Update(ctx context.Context, session mgauthn.Session, cfg b
return es.Publish(ctx, ev)
}
func (es eventStore) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
func (es eventStore) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
cfg, err := es.svc.UpdateCert(ctx, session, clientID, clientCert, clientKey, caCert)
if err != nil {
return cfg, err
@@ -92,7 +92,7 @@ func (es eventStore) UpdateCert(ctx context.Context, session mgauthn.Session, cl
return cfg, nil
}
func (es *eventStore) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) error {
func (es *eventStore) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) error {
if err := es.svc.UpdateConnections(ctx, session, token, id, connections); err != nil {
return err
}
@@ -105,7 +105,7 @@ func (es *eventStore) UpdateConnections(ctx context.Context, session mgauthn.Ses
return es.Publish(ctx, ev)
}
func (es *eventStore) List(ctx context.Context, session mgauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
func (es *eventStore) List(ctx context.Context, session smqauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
bp, err := es.svc.List(ctx, session, filter, offset, limit)
if err != nil {
return bp, err
@@ -125,7 +125,7 @@ func (es *eventStore) List(ctx context.Context, session mgauthn.Session, filter
return bp, nil
}
func (es *eventStore) Remove(ctx context.Context, session mgauthn.Session, id string) error {
func (es *eventStore) Remove(ctx context.Context, session smqauthn.Session, id string) error {
if err := es.svc.Remove(ctx, session, id); err != nil {
return err
}
@@ -157,7 +157,7 @@ func (es *eventStore) Bootstrap(ctx context.Context, externalKey, externalID str
return cfg, err
}
func (es *eventStore) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state bootstrap.State) error {
func (es *eventStore) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state bootstrap.State) error {
if err := es.svc.ChangeState(ctx, session, token, id, state); err != nil {
return err
}
+37 -37
View File
@@ -11,20 +11,20 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/bootstrap/events/producer"
"github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/authn"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/events/store"
policysvc "github.com/absmach/magistrala/pkg/policies"
policymocks "github.com/absmach/magistrala/pkg/policies/mocks"
mgsdk "github.com/absmach/magistrala/pkg/sdk/go"
sdkmocks "github.com/absmach/magistrala/pkg/sdk/mocks"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/bootstrap/events/producer"
"github.com/absmach/supermq/bootstrap/mocks"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/authn"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/absmach/supermq/pkg/events/store"
policysvc "github.com/absmach/supermq/pkg/policies"
policymocks "github.com/absmach/supermq/pkg/policies/mocks"
mgsdk "github.com/absmach/supermq/pkg/sdk/go"
sdkmocks "github.com/absmach/supermq/pkg/sdk/mocks"
"github.com/absmach/supermq/pkg/uuid"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
@@ -32,7 +32,7 @@ import (
)
const (
streamID = "magistrala.bootstrap"
streamID = "supermq.bootstrap"
email = "user@example.com"
validToken = "validToken"
invalidToken = "invalid"
@@ -128,7 +128,7 @@ func TestAdd(t *testing.T) {
desc string
config bootstrap.Config
token string
session mgauthn.Session
session smqauthn.Session
id string
domainID string
clientErr error
@@ -191,7 +191,7 @@ func TestAdd(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
sdkCall := tv.sdk.On("Client", tc.config.ClientID, tc.domainID, tc.token).Return(mgsdk.Client{ID: tc.config.ClientID, Credentials: mgsdk.ClientCredentials{Secret: tc.config.ClientSecret}}, errors.NewSDKError(tc.clientErr))
repoCall := tv.boot.On("ListExisting", context.Background(), domainID, mock.Anything).Return(tc.config.Channels, tc.listErr)
repoCall1 := tv.boot.On("Save", context.Background(), mock.Anything, mock.Anything).Return(mock.Anything, tc.saveErr)
@@ -232,7 +232,7 @@ func TestView(t *testing.T) {
desc string
config bootstrap.Config
token string
session mgauthn.Session
session smqauthn.Session
id string
domainID string
retrieveErr error
@@ -271,7 +271,7 @@ func TestView(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("RetrieveByID", context.Background(), tc.domainID, tc.config.ClientID).Return(config, tc.retrieveErr)
_, err := tv.svc.View(context.Background(), tc.session, tc.config.ClientID)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -324,7 +324,7 @@ func TestUpdate(t *testing.T) {
desc string
config bootstrap.Config
token string
session mgauthn.Session
session smqauthn.Session
id string
domainID string
updateErr error
@@ -365,7 +365,7 @@ func TestUpdate(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("Update", context.Background(), mock.Anything).Return(tc.updateErr)
err := tv.svc.Update(context.Background(), tc.session, tc.config)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -401,7 +401,7 @@ func TestUpdateConnections(t *testing.T) {
id string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
connections []string
clientErr error
channelErr error
@@ -474,7 +474,7 @@ func TestUpdateConnections(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
sdkCall := tv.sdk.On("Channel", mock.Anything, tc.domainID, tc.token).Return(mgsdk.Channel{}, tc.channelErr)
repoCall := tv.boot.On("RetrieveByID", context.Background(), tc.domainID, tc.configID).Return(config, tc.retrieveErr)
repoCall1 := tv.boot.On("ListExisting", context.Background(), domainID, mock.Anything, mock.Anything).Return(config.Channels, tc.listErr)
@@ -514,7 +514,7 @@ func TestUpdateCert(t *testing.T) {
userID string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
clientCert string
clientKey string
caCert string
@@ -612,7 +612,7 @@ func TestUpdateCert(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("UpdateCert", context.Background(), tc.domainID, tc.configID, tc.clientCert, tc.clientKey, tc.caCert).Return(config, tc.updateErr)
_, err := tv.svc.UpdateCert(context.Background(), tc.session, tc.configID, tc.clientCert, tc.clientKey, tc.caCert)
@@ -656,7 +656,7 @@ func TestList(t *testing.T) {
cases := []struct {
desc string
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
config bootstrap.ConfigsPage
@@ -674,7 +674,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
config: bootstrap.ConfigsPage{
Total: uint64(len(saved)),
Offset: 0,
@@ -702,7 +702,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
config: bootstrap.ConfigsPage{
Total: uint64(len(saved)),
Offset: 0,
@@ -730,7 +730,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
config: bootstrap.ConfigsPage{
Total: uint64(len(saved)),
Offset: 0,
@@ -758,7 +758,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
filter: bootstrap.Filter{},
offset: 0,
limit: 10,
@@ -773,7 +773,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
filter: bootstrap.Filter{},
offset: 0,
limit: 10,
@@ -787,7 +787,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
filter: bootstrap.Filter{},
offset: 0,
limit: 10,
@@ -801,7 +801,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
filter: bootstrap.Filter{},
offset: 0,
limit: 10,
@@ -859,7 +859,7 @@ func TestRemove(t *testing.T) {
userID string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
removeErr error
err error
event map[string]interface{}
@@ -891,7 +891,7 @@ func TestRemove(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("Remove", context.Background(), mock.Anything, mock.Anything).Return(tc.removeErr)
err := tv.svc.Remove(context.Background(), tc.session, tc.configID)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -988,7 +988,7 @@ func TestChangeState(t *testing.T) {
userID string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
state bootstrap.State
authResponse authn.Session
authorizeErr error
@@ -1052,7 +1052,7 @@ func TestChangeState(t *testing.T) {
lastID := "0"
for _, tc := range cases {
tc.session = mgauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: validID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := tv.boot.On("RetrieveByID", context.Background(), tc.domainID, tc.id).Return(config, tc.retrieveErr)
sdkCall1 := tv.sdk.On("ConnectClient", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(errors.NewSDKError(tc.connectErr))
repoCall1 := tv.boot.On("ChangeState", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(tc.stateErr)
+16 -16
View File
@@ -6,29 +6,29 @@ package middleware
import (
"context"
"github.com/absmach/magistrala/bootstrap"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/authz"
mgauthz "github.com/absmach/magistrala/pkg/authz"
"github.com/absmach/magistrala/pkg/policies"
"github.com/absmach/supermq/bootstrap"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/authz"
smqauthz "github.com/absmach/supermq/pkg/authz"
"github.com/absmach/supermq/pkg/policies"
)
var _ bootstrap.Service = (*authorizationMiddleware)(nil)
type authorizationMiddleware struct {
svc bootstrap.Service
authz mgauthz.Authorization
authz smqauthz.Authorization
}
// AuthorizationMiddleware adds authorization to the clients service.
func AuthorizationMiddleware(svc bootstrap.Service, authz mgauthz.Authorization) bootstrap.Service {
func AuthorizationMiddleware(svc bootstrap.Service, authz smqauthz.Authorization) bootstrap.Service {
return &authorizationMiddleware{
svc: svc,
authz: authz,
}
}
func (am *authorizationMiddleware) Add(ctx context.Context, session mgauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
func (am *authorizationMiddleware) Add(ctx context.Context, session smqauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
if err := am.authorize(ctx, "", policies.UserType, policies.UsersKind, session.DomainUserID, policies.MembershipPermission, policies.DomainType, session.DomainID); err != nil {
return bootstrap.Config{}, err
}
@@ -36,7 +36,7 @@ func (am *authorizationMiddleware) Add(ctx context.Context, session mgauthn.Sess
return am.svc.Add(ctx, session, token, cfg)
}
func (am *authorizationMiddleware) View(ctx context.Context, session mgauthn.Session, id string) (bootstrap.Config, error) {
func (am *authorizationMiddleware) View(ctx context.Context, session smqauthn.Session, id string) (bootstrap.Config, error) {
if err := am.authorize(ctx, session.DomainID, policies.UserType, policies.UsersKind, session.DomainUserID, policies.ViewPermission, policies.ClientType, id); err != nil {
return bootstrap.Config{}, err
}
@@ -44,7 +44,7 @@ func (am *authorizationMiddleware) View(ctx context.Context, session mgauthn.Ses
return am.svc.View(ctx, session, id)
}
func (am *authorizationMiddleware) Update(ctx context.Context, session mgauthn.Session, cfg bootstrap.Config) error {
func (am *authorizationMiddleware) Update(ctx context.Context, session smqauthn.Session, cfg bootstrap.Config) error {
if err := am.authorize(ctx, session.DomainID, policies.UserType, policies.UsersKind, session.DomainUserID, policies.EditPermission, policies.ClientType, cfg.ClientID); err != nil {
return err
}
@@ -52,7 +52,7 @@ func (am *authorizationMiddleware) Update(ctx context.Context, session mgauthn.S
return am.svc.Update(ctx, session, cfg)
}
func (am *authorizationMiddleware) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
func (am *authorizationMiddleware) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
if err := am.authorize(ctx, session.DomainID, policies.UserType, policies.UsersKind, session.DomainUserID, policies.EditPermission, policies.ClientType, clientID); err != nil {
return bootstrap.Config{}, err
}
@@ -60,7 +60,7 @@ func (am *authorizationMiddleware) UpdateCert(ctx context.Context, session mgaut
return am.svc.UpdateCert(ctx, session, clientID, clientCert, clientKey, caCert)
}
func (am *authorizationMiddleware) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) error {
func (am *authorizationMiddleware) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) error {
if err := am.authorize(ctx, session.DomainID, policies.UserType, policies.UsersKind, session.DomainUserID, policies.EditPermission, policies.ClientType, id); err != nil {
return err
}
@@ -68,7 +68,7 @@ func (am *authorizationMiddleware) UpdateConnections(ctx context.Context, sessio
return am.svc.UpdateConnections(ctx, session, token, id, connections)
}
func (am *authorizationMiddleware) List(ctx context.Context, session mgauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
func (am *authorizationMiddleware) List(ctx context.Context, session smqauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
if err := am.checkSuperAdmin(ctx, session.DomainUserID); err == nil {
session.SuperAdmin = true
}
@@ -79,7 +79,7 @@ func (am *authorizationMiddleware) List(ctx context.Context, session mgauthn.Ses
return am.svc.List(ctx, session, filter, offset, limit)
}
func (am *authorizationMiddleware) Remove(ctx context.Context, session mgauthn.Session, id string) error {
func (am *authorizationMiddleware) Remove(ctx context.Context, session smqauthn.Session, id string) error {
if err := am.authorize(ctx, session.DomainID, policies.UserType, policies.UsersKind, session.DomainUserID, policies.DeletePermission, policies.ClientType, id); err != nil {
return err
}
@@ -91,7 +91,7 @@ func (am *authorizationMiddleware) Bootstrap(ctx context.Context, externalKey, e
return am.svc.Bootstrap(ctx, externalKey, externalID, secure)
}
func (am *authorizationMiddleware) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state bootstrap.State) error {
func (am *authorizationMiddleware) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state bootstrap.State) error {
return am.svc.ChangeState(ctx, session, token, id, state)
}
@@ -121,7 +121,7 @@ func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, adminID
Subject: adminID,
Permission: policies.AdminPermission,
ObjectType: policies.PlatformType,
Object: policies.MagistralaObject,
Object: policies.SuperMQObject,
}); err != nil {
return err
}
+10 -10
View File
@@ -10,8 +10,8 @@ import (
"log/slog"
"time"
"github.com/absmach/magistrala/bootstrap"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/supermq/bootstrap"
smqauthn "github.com/absmach/supermq/pkg/authn"
)
var _ bootstrap.Service = (*loggingMiddleware)(nil)
@@ -28,7 +28,7 @@ func LoggingMiddleware(svc bootstrap.Service, logger *slog.Logger) bootstrap.Ser
// Add logs the add request. It logs the client ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) Add(ctx context.Context, session mgauthn.Session, token string, cfg bootstrap.Config) (saved bootstrap.Config, err error) {
func (lm *loggingMiddleware) Add(ctx context.Context, session smqauthn.Session, token string, cfg bootstrap.Config) (saved bootstrap.Config, err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -47,7 +47,7 @@ func (lm *loggingMiddleware) Add(ctx context.Context, session mgauthn.Session, t
// View logs the view request. It logs the client ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) View(ctx context.Context, session mgauthn.Session, id string) (saved bootstrap.Config, err error) {
func (lm *loggingMiddleware) View(ctx context.Context, session smqauthn.Session, id string) (saved bootstrap.Config, err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -66,7 +66,7 @@ func (lm *loggingMiddleware) View(ctx context.Context, session mgauthn.Session,
// Update logs the update request. It logs bootstrap client ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) Update(ctx context.Context, session mgauthn.Session, cfg bootstrap.Config) (err error) {
func (lm *loggingMiddleware) Update(ctx context.Context, session smqauthn.Session, cfg bootstrap.Config) (err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -88,7 +88,7 @@ func (lm *loggingMiddleware) Update(ctx context.Context, session mgauthn.Session
// UpdateCert logs the update_cert request. It logs client ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (cfg bootstrap.Config, err error) {
func (lm *loggingMiddleware) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (cfg bootstrap.Config, err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -107,7 +107,7 @@ func (lm *loggingMiddleware) UpdateCert(ctx context.Context, session mgauthn.Ses
// UpdateConnections logs the update_connections request. It logs bootstrap ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) (err error) {
func (lm *loggingMiddleware) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) (err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -127,7 +127,7 @@ func (lm *loggingMiddleware) UpdateConnections(ctx context.Context, session mgau
// List logs the list request. It logs offset, limit and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) List(ctx context.Context, session mgauthn.Session, filter bootstrap.Filter, offset, limit uint64) (res bootstrap.ConfigsPage, err error) {
func (lm *loggingMiddleware) List(ctx context.Context, session smqauthn.Session, filter bootstrap.Filter, offset, limit uint64) (res bootstrap.ConfigsPage, err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -151,7 +151,7 @@ func (lm *loggingMiddleware) List(ctx context.Context, session mgauthn.Session,
// Remove logs the remove request. It logs bootstrap ID and the time it took to complete the request.
// If the request fails, it logs the error.
func (lm *loggingMiddleware) Remove(ctx context.Context, session mgauthn.Session, id string) (err error) {
func (lm *loggingMiddleware) Remove(ctx context.Context, session smqauthn.Session, id string) (err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
@@ -185,7 +185,7 @@ func (lm *loggingMiddleware) Bootstrap(ctx context.Context, externalKey, externa
return lm.svc.Bootstrap(ctx, externalKey, externalID, secure)
}
func (lm *loggingMiddleware) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state bootstrap.State) (err error) {
func (lm *loggingMiddleware) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state bootstrap.State) (err error) {
defer func(begin time.Time) {
args := []any{
slog.String("duration", time.Since(begin).String()),
+10 -10
View File
@@ -9,8 +9,8 @@ import (
"context"
"time"
"github.com/absmach/magistrala/bootstrap"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/supermq/bootstrap"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/go-kit/kit/metrics"
)
@@ -32,7 +32,7 @@ func MetricsMiddleware(svc bootstrap.Service, counter metrics.Counter, latency m
}
// Add instruments Add method with metrics.
func (mm *metricsMiddleware) Add(ctx context.Context, session mgauthn.Session, token string, cfg bootstrap.Config) (saved bootstrap.Config, err error) {
func (mm *metricsMiddleware) Add(ctx context.Context, session smqauthn.Session, token string, cfg bootstrap.Config) (saved bootstrap.Config, err error) {
defer func(begin time.Time) {
mm.counter.With("method", "add").Add(1)
mm.latency.With("method", "add").Observe(time.Since(begin).Seconds())
@@ -42,7 +42,7 @@ func (mm *metricsMiddleware) Add(ctx context.Context, session mgauthn.Session, t
}
// View instruments View method with metrics.
func (mm *metricsMiddleware) View(ctx context.Context, session mgauthn.Session, id string) (saved bootstrap.Config, err error) {
func (mm *metricsMiddleware) View(ctx context.Context, session smqauthn.Session, id string) (saved bootstrap.Config, err error) {
defer func(begin time.Time) {
mm.counter.With("method", "view").Add(1)
mm.latency.With("method", "view").Observe(time.Since(begin).Seconds())
@@ -52,7 +52,7 @@ func (mm *metricsMiddleware) View(ctx context.Context, session mgauthn.Session,
}
// Update instruments Update method with metrics.
func (mm *metricsMiddleware) Update(ctx context.Context, session mgauthn.Session, cfg bootstrap.Config) (err error) {
func (mm *metricsMiddleware) Update(ctx context.Context, session smqauthn.Session, cfg bootstrap.Config) (err error) {
defer func(begin time.Time) {
mm.counter.With("method", "update").Add(1)
mm.latency.With("method", "update").Observe(time.Since(begin).Seconds())
@@ -62,7 +62,7 @@ func (mm *metricsMiddleware) Update(ctx context.Context, session mgauthn.Session
}
// UpdateCert instruments UpdateCert method with metrics.
func (mm *metricsMiddleware) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (cfg bootstrap.Config, err error) {
func (mm *metricsMiddleware) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (cfg bootstrap.Config, err error) {
defer func(begin time.Time) {
mm.counter.With("method", "update_cert").Add(1)
mm.latency.With("method", "update_cert").Observe(time.Since(begin).Seconds())
@@ -72,7 +72,7 @@ func (mm *metricsMiddleware) UpdateCert(ctx context.Context, session mgauthn.Ses
}
// UpdateConnections instruments UpdateConnections method with metrics.
func (mm *metricsMiddleware) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) (err error) {
func (mm *metricsMiddleware) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) (err error) {
defer func(begin time.Time) {
mm.counter.With("method", "update_connections").Add(1)
mm.latency.With("method", "update_connections").Observe(time.Since(begin).Seconds())
@@ -82,7 +82,7 @@ func (mm *metricsMiddleware) UpdateConnections(ctx context.Context, session mgau
}
// List instruments List method with metrics.
func (mm *metricsMiddleware) List(ctx context.Context, session mgauthn.Session, filter bootstrap.Filter, offset, limit uint64) (saved bootstrap.ConfigsPage, err error) {
func (mm *metricsMiddleware) List(ctx context.Context, session smqauthn.Session, filter bootstrap.Filter, offset, limit uint64) (saved bootstrap.ConfigsPage, err error) {
defer func(begin time.Time) {
mm.counter.With("method", "list").Add(1)
mm.latency.With("method", "list").Observe(time.Since(begin).Seconds())
@@ -92,7 +92,7 @@ func (mm *metricsMiddleware) List(ctx context.Context, session mgauthn.Session,
}
// Remove instruments Remove method with metrics.
func (mm *metricsMiddleware) Remove(ctx context.Context, session mgauthn.Session, id string) (err error) {
func (mm *metricsMiddleware) Remove(ctx context.Context, session smqauthn.Session, id string) (err error) {
defer func(begin time.Time) {
mm.counter.With("method", "remove").Add(1)
mm.latency.With("method", "remove").Observe(time.Since(begin).Seconds())
@@ -112,7 +112,7 @@ func (mm *metricsMiddleware) Bootstrap(ctx context.Context, externalKey, externa
}
// ChangeState instruments ChangeState method with metrics.
func (mm *metricsMiddleware) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state bootstrap.State) (err error) {
func (mm *metricsMiddleware) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state bootstrap.State) (err error) {
defer func(begin time.Time) {
mm.counter.With("method", "change_state").Add(1)
mm.latency.With("method", "change_state").Observe(time.Since(begin).Seconds())
+1 -1
View File
@@ -5,7 +5,7 @@
package mocks
import (
bootstrap "github.com/absmach/magistrala/bootstrap"
bootstrap "github.com/absmach/supermq/bootstrap"
mock "github.com/stretchr/testify/mock"
)
+1 -1
View File
@@ -7,7 +7,7 @@ package mocks
import (
context "context"
bootstrap "github.com/absmach/magistrala/bootstrap"
bootstrap "github.com/absmach/supermq/bootstrap"
mock "github.com/stretchr/testify/mock"
)
+2 -2
View File
@@ -5,8 +5,8 @@
package mocks
import (
bootstrap "github.com/absmach/magistrala/bootstrap"
authn "github.com/absmach/magistrala/pkg/authn"
bootstrap "github.com/absmach/supermq/bootstrap"
authn "github.com/absmach/supermq/pkg/authn"
context "context"
+5 -5
View File
@@ -12,11 +12,11 @@ import (
"strings"
"time"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/clients"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
"github.com/absmach/magistrala/pkg/postgres"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/clients"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
"github.com/absmach/supermq/pkg/postgres"
"github.com/jackc/pgerrcode"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v5/pgconn"
+7 -7
View File
@@ -9,11 +9,11 @@ import (
"strconv"
"testing"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/bootstrap/postgres"
"github.com/absmach/magistrala/internal/testsutil"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/bootstrap/postgres"
"github.com/absmach/supermq/internal/testsutil"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -23,8 +23,8 @@ const numConfigs = 10
var (
config = bootstrap.Config{
ClientID: "mg-client",
ClientSecret: "mg-key",
ClientID: "smq-client",
ClientSecret: "smq-key",
ExternalID: "external-id",
ExternalKey: "external-key",
DomainID: testsutil.GenerateUUID(&testing.T{}),
+4 -4
View File
@@ -9,16 +9,16 @@ import (
"os"
"testing"
"github.com/absmach/magistrala/bootstrap/postgres"
mglog "github.com/absmach/magistrala/logger"
pgclient "github.com/absmach/magistrala/pkg/postgres"
"github.com/absmach/supermq/bootstrap/postgres"
smqlog "github.com/absmach/supermq/logger"
pgclient "github.com/absmach/supermq/pkg/postgres"
"github.com/jmoiron/sqlx"
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
)
var (
testLog, _ = mglog.New(os.Stdout, "info")
testLog, _ = smqlog.New(os.Stdout, "info")
db *sqlx.DB
)
+1 -1
View File
@@ -12,7 +12,7 @@ import (
"net/http"
)
// bootstrapRes represent Magistrala Response to the Bootatrap request.
// bootstrapRes represent SuperMQ Response to the Bootatrap request.
// This is used as a response from ConfigReader and can easily be
// replace with any other response format.
type bootstrapRes struct {
+12 -12
View File
@@ -11,9 +11,9 @@ import (
"net/http"
"testing"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/supermq"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/pkg/errors"
"github.com/stretchr/testify/assert"
)
@@ -50,27 +50,27 @@ func dec(in []byte) ([]byte, error) {
func TestReadConfig(t *testing.T) {
cfg := bootstrap.Config{
ClientID: "mg_id",
ClientID: "smq_id",
ClientCert: "client_cert",
ClientKey: "client_key",
CACert: "ca_cert",
ClientSecret: "mg_key",
ClientSecret: "smq_key",
Channels: []bootstrap.Channel{
{
ID: "mg_id",
Name: "mg_name",
ID: "smq_id",
Name: "smq_name",
Metadata: map[string]interface{}{"key": "value}"},
},
},
Content: "content",
}
ret := readResp{
ClientID: "mg_id",
ClientSecret: "mg_key",
ClientID: "smq_id",
ClientSecret: "smq_key",
Channels: []readChan{
{
ID: "mg_id",
Name: "mg_name",
ID: "smq_id",
Name: "smq_name",
Metadata: map[string]interface{}{"key": "value}"},
},
},
@@ -118,7 +118,7 @@ func TestReadConfig(t *testing.T) {
b, err := json.Marshal(res)
assert.Nil(t, err, fmt.Sprintf("Marshalling expected to succeed: %s.\n", err))
assert.Equal(t, tc.enc, b, fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.enc, b))
resp, ok := res.(magistrala.Response)
resp, ok := res.(supermq.Response)
assert.True(t, ok, "If not encrypted, reader should return response.")
assert.False(t, resp.Empty(), fmt.Sprintf("Response should not be empty %s.", err))
assert.Equal(t, http.StatusOK, resp.Code(), "Default config response code should be 200.")
+27 -27
View File
@@ -9,17 +9,17 @@ import (
"crypto/cipher"
"encoding/hex"
"github.com/absmach/magistrala"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
repoerr "github.com/absmach/magistrala/pkg/errors/repository"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/magistrala/pkg/policies"
mgsdk "github.com/absmach/magistrala/pkg/sdk/go"
"github.com/absmach/supermq"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
repoerr "github.com/absmach/supermq/pkg/errors/repository"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/absmach/supermq/pkg/policies"
mgsdk "github.com/absmach/supermq/pkg/sdk/go"
)
var (
// ErrClients indicates failure to communicate with Magistrala Clients service.
// ErrClients indicates failure to communicate with SuperMQ Clients service.
// It can be due to networking error or invalid/unauthenticated request.
ErrClients = errors.New("failed to receive response from Clients service")
@@ -61,33 +61,33 @@ var _ Service = (*bootstrapService)(nil)
//go:generate mockery --name Service --output=./mocks --filename service.go --quiet --note "Copyright (c) Abstract Machines"
type Service interface {
// Add adds new Client Config to the user identified by the provided token.
Add(ctx context.Context, session mgauthn.Session, token string, cfg Config) (Config, error)
Add(ctx context.Context, session smqauthn.Session, token string, cfg Config) (Config, error)
// View returns Client Config with given ID belonging to the user identified by the given token.
View(ctx context.Context, session mgauthn.Session, id string) (Config, error)
View(ctx context.Context, session smqauthn.Session, id string) (Config, error)
// Update updates editable fields of the provided Config.
Update(ctx context.Context, session mgauthn.Session, cfg Config) error
Update(ctx context.Context, session smqauthn.Session, cfg Config) error
// UpdateCert updates an existing Config certificate and token.
// A non-nil error is returned to indicate operation failure.
UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (Config, error)
UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (Config, error)
// UpdateConnections updates list of Channels related to given Config.
UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) error
UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) error
// List returns subset of Configs with given search params that belong to the
// user identified by the given token.
List(ctx context.Context, session mgauthn.Session, filter Filter, offset, limit uint64) (ConfigsPage, error)
List(ctx context.Context, session smqauthn.Session, filter Filter, offset, limit uint64) (ConfigsPage, error)
// Remove removes Config with specified token that belongs to the user identified by the given token.
Remove(ctx context.Context, session mgauthn.Session, id string) error
Remove(ctx context.Context, session smqauthn.Session, id string) error
// Bootstrap returns Config to the Client with provided external ID using external key.
Bootstrap(ctx context.Context, externalKey, externalID string, secure bool) (Config, error)
// ChangeState changes state of the Client with given client ID and domain ID.
ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state State) error
ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state State) error
// Methods RemoveConfig, UpdateChannel, and RemoveChannel are used as
// handlers for events. That's why these methods surpass ownership check.
@@ -123,11 +123,11 @@ type bootstrapService struct {
configs ConfigRepository
sdk mgsdk.SDK
encKey []byte
idProvider magistrala.IDProvider
idProvider supermq.IDProvider
}
// New returns new Bootstrap service.
func New(policyService policies.Service, configs ConfigRepository, sdk mgsdk.SDK, encKey []byte, idp magistrala.IDProvider) Service {
func New(policyService policies.Service, configs ConfigRepository, sdk mgsdk.SDK, encKey []byte, idp supermq.IDProvider) Service {
return &bootstrapService{
configs: configs,
sdk: sdk,
@@ -137,7 +137,7 @@ func New(policyService policies.Service, configs ConfigRepository, sdk mgsdk.SDK
}
}
func (bs bootstrapService) Add(ctx context.Context, session mgauthn.Session, token string, cfg Config) (Config, error) {
func (bs bootstrapService) Add(ctx context.Context, session smqauthn.Session, token string, cfg Config) (Config, error) {
toConnect := bs.toIDList(cfg.Channels)
// Check if channels exist. This is the way to prevent fetching channels that already exist.
@@ -186,7 +186,7 @@ func (bs bootstrapService) Add(ctx context.Context, session mgauthn.Session, tok
return cfg, nil
}
func (bs bootstrapService) View(ctx context.Context, session mgauthn.Session, id string) (Config, error) {
func (bs bootstrapService) View(ctx context.Context, session smqauthn.Session, id string) (Config, error) {
cfg, err := bs.configs.RetrieveByID(ctx, session.DomainID, id)
if err != nil {
return Config{}, errors.Wrap(svcerr.ErrViewEntity, err)
@@ -194,7 +194,7 @@ func (bs bootstrapService) View(ctx context.Context, session mgauthn.Session, id
return cfg, nil
}
func (bs bootstrapService) Update(ctx context.Context, session mgauthn.Session, cfg Config) error {
func (bs bootstrapService) Update(ctx context.Context, session smqauthn.Session, cfg Config) error {
cfg.DomainID = session.DomainID
if err := bs.configs.Update(ctx, cfg); err != nil {
return errors.Wrap(errUpdateConnections, err)
@@ -202,7 +202,7 @@ func (bs bootstrapService) Update(ctx context.Context, session mgauthn.Session,
return nil
}
func (bs bootstrapService) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (Config, error) {
func (bs bootstrapService) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (Config, error) {
cfg, err := bs.configs.UpdateCert(ctx, session.DomainID, clientID, clientCert, clientKey, caCert)
if err != nil {
return Config{}, errors.Wrap(errUpdateCert, err)
@@ -210,7 +210,7 @@ func (bs bootstrapService) UpdateCert(ctx context.Context, session mgauthn.Sessi
return cfg, nil
}
func (bs bootstrapService) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) error {
func (bs bootstrapService) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) error {
cfg, err := bs.configs.RetrieveByID(ctx, session.DomainID, id)
if err != nil {
return errors.Wrap(errUpdateConnections, err)
@@ -275,7 +275,7 @@ func (bs bootstrapService) listClientIDs(ctx context.Context, userID string) ([]
return tids.Policies, nil
}
func (bs bootstrapService) List(ctx context.Context, session mgauthn.Session, filter Filter, offset, limit uint64) (ConfigsPage, error) {
func (bs bootstrapService) List(ctx context.Context, session smqauthn.Session, filter Filter, offset, limit uint64) (ConfigsPage, error) {
if session.SuperAdmin {
return bs.configs.RetrieveAll(ctx, session.DomainID, []string{}, filter, offset, limit), nil
}
@@ -298,7 +298,7 @@ func (bs bootstrapService) List(ctx context.Context, session mgauthn.Session, fi
return bs.configs.RetrieveAll(ctx, session.DomainID, clientIDs, filter, offset, limit), nil
}
func (bs bootstrapService) Remove(ctx context.Context, session mgauthn.Session, id string) error {
func (bs bootstrapService) Remove(ctx context.Context, session smqauthn.Session, id string) error {
if err := bs.configs.Remove(ctx, session.DomainID, id); err != nil {
return errors.Wrap(errRemoveBootstrap, err)
}
@@ -324,7 +324,7 @@ func (bs bootstrapService) Bootstrap(ctx context.Context, externalKey, externalI
return cfg, nil
}
func (bs bootstrapService) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state State) error {
func (bs bootstrapService) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state State) error {
cfg, err := bs.configs.RetrieveByID(ctx, session.DomainID, id)
if err != nil {
return errors.Wrap(errChangeState, err)
@@ -396,7 +396,7 @@ func (bs bootstrapService) DisconnectClientHandler(ctx context.Context, channelI
return nil
}
// Method client retrieves Magistrala Client creating one if an empty ID is passed.
// Method client retrieves SuperMQ Client creating one if an empty ID is passed.
func (bs bootstrapService) client(domainID, id, token string) (mgsdk.Client, error) {
// If Client ID is not provided, then create new client.
if id == "" {
+40 -40
View File
@@ -14,17 +14,17 @@ import (
"sort"
"testing"
"github.com/absmach/magistrala/bootstrap"
"github.com/absmach/magistrala/bootstrap/mocks"
"github.com/absmach/magistrala/internal/testsutil"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
policysvc "github.com/absmach/magistrala/pkg/policies"
policymocks "github.com/absmach/magistrala/pkg/policies/mocks"
mgsdk "github.com/absmach/magistrala/pkg/sdk/go"
sdkmocks "github.com/absmach/magistrala/pkg/sdk/mocks"
"github.com/absmach/magistrala/pkg/uuid"
"github.com/absmach/supermq/bootstrap"
"github.com/absmach/supermq/bootstrap/mocks"
"github.com/absmach/supermq/internal/testsutil"
smqauthn "github.com/absmach/supermq/pkg/authn"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
policysvc "github.com/absmach/supermq/pkg/policies"
policymocks "github.com/absmach/supermq/pkg/policies/mocks"
mgsdk "github.com/absmach/supermq/pkg/sdk/go"
sdkmocks "github.com/absmach/supermq/pkg/sdk/mocks"
"github.com/absmach/supermq/pkg/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -103,7 +103,7 @@ func TestAdd(t *testing.T) {
desc string
config bootstrap.Config
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
clientErr error
@@ -151,7 +151,7 @@ func TestAdd(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := sdk.On("Client", tc.config.ClientID, mock.Anything, tc.token).Return(mgsdk.Client{ID: tc.config.ClientID, Credentials: mgsdk.ClientCredentials{Secret: tc.config.ClientSecret}}, tc.clientErr)
repoCall1 := sdk.On("CreateClient", mock.Anything, tc.domainID, tc.token).Return(mgsdk.Client{}, tc.createClientErr)
repoCall2 := sdk.On("DeleteClient", tc.config.ClientID, tc.domainID, tc.token).Return(tc.deleteClientErr)
@@ -178,7 +178,7 @@ func TestView(t *testing.T) {
domain string
clientDomain string
token string
session mgauthn.Session
session smqauthn.Session
retrieveErr error
clientErr error
channelErr error
@@ -217,7 +217,7 @@ func TestView(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domain, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domain, DomainUserID: validID}
repoCall := boot.On("RetrieveByID", context.Background(), tc.clientDomain, tc.configID).Return(config, tc.retrieveErr)
_, err := svc.View(context.Background(), tc.session, tc.configID)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -245,7 +245,7 @@ func TestUpdate(t *testing.T) {
desc string
config bootstrap.Config
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
updateErr error
@@ -281,7 +281,7 @@ func TestUpdate(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := boot.On("Update", context.Background(), mock.Anything).Return(tc.updateErr)
err := svc.Update(context.Background(), tc.session, tc.config)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -301,7 +301,7 @@ func TestUpdateCert(t *testing.T) {
cases := []struct {
desc string
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
clientID string
@@ -356,7 +356,7 @@ func TestUpdateCert(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := boot.On("UpdateCert", context.Background(), mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tc.expectedConfig, tc.updateErr)
cfg, err := svc.UpdateCert(context.Background(), tc.session, tc.clientID, tc.clientCert, tc.clientKey, tc.caCert)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -386,7 +386,7 @@ func TestUpdateConnections(t *testing.T) {
cases := []struct {
desc string
token string
session mgauthn.Session
session smqauthn.Session
id string
state bootstrap.State
userID string
@@ -433,7 +433,7 @@ func TestUpdateConnections(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
sdkCall := sdk.On("Channel", mock.Anything, tc.domainID, tc.token).Return(mgsdk.Channel{}, tc.channelErr)
repoCall := boot.On("RetrieveByID", context.Background(), tc.domainID, tc.id).Return(c, tc.retrieveErr)
repoCall1 := boot.On("ListExisting", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(c.Channels, tc.listErr)
@@ -470,7 +470,7 @@ func TestList(t *testing.T) {
offset uint64
limit uint64
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
listObjectsResponse policysvc.PolicyPage
@@ -488,7 +488,7 @@ func TestList(t *testing.T) {
},
filter: bootstrap.Filter{},
token: validToken,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
userID: validID,
domainID: domainID,
offset: 0,
@@ -500,7 +500,7 @@ func TestList(t *testing.T) {
config: bootstrap.ConfigsPage{},
filter: bootstrap.Filter{},
token: validID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
userID: validID,
domainID: domainID,
listObjectsResponse: policysvc.PolicyPage{},
@@ -520,7 +520,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
listObjectsResponse: policysvc.PolicyPage{},
offset: 0,
limit: 10,
@@ -538,7 +538,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
listObjectsResponse: policysvc.PolicyPage{Policies: []string{"test", "test"}},
offset: 0,
limit: 10,
@@ -554,7 +554,7 @@ func TestList(t *testing.T) {
},
filter: bootstrap.Filter{PartialMatch: map[string]string{"name": "95"}},
token: validToken,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
userID: validID,
domainID: domainID,
offset: 0,
@@ -573,7 +573,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
offset: 0,
limit: 100,
err: nil,
@@ -590,7 +590,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
listObjectsResponse: policysvc.PolicyPage{Policies: []string{"test", "test"}},
offset: 0,
limit: 100,
@@ -608,7 +608,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
offset: 95,
limit: 10,
err: nil,
@@ -625,7 +625,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
offset: 95,
limit: 10,
err: nil,
@@ -642,7 +642,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
listObjectsResponse: policysvc.PolicyPage{Policies: []string{"test", "test"}},
offset: 95,
limit: 10,
@@ -660,7 +660,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
offset: 35,
limit: 20,
err: nil,
@@ -677,7 +677,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID, SuperAdmin: true},
offset: 35,
limit: 20,
err: nil,
@@ -694,7 +694,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
listObjectsResponse: policysvc.PolicyPage{Policies: []string{"test", "test"}},
offset: 35,
limit: 20,
@@ -709,7 +709,7 @@ func TestList(t *testing.T) {
token: validToken,
userID: validID,
domainID: domainID,
session: mgauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
session: smqauthn.Session{UserID: validID, DomainID: domainID, DomainUserID: validID},
listObjectsResponse: policysvc.PolicyPage{},
listObjectsErr: svcerr.ErrNotFound,
err: svcerr.ErrNotFound,
@@ -744,7 +744,7 @@ func TestRemove(t *testing.T) {
desc string
id string
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
removeErr error
@@ -779,7 +779,7 @@ func TestRemove(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := boot.On("Remove", context.Background(), mock.Anything, mock.Anything).Return(tc.removeErr)
err := svc.Remove(context.Background(), tc.session, tc.id)
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))
@@ -867,7 +867,7 @@ func TestChangeState(t *testing.T) {
state bootstrap.State
id string
token string
session mgauthn.Session
session smqauthn.Session
userID string
domainID string
retrieveErr error
@@ -937,7 +937,7 @@ func TestChangeState(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
tc.session = mgauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
tc.session = smqauthn.Session{UserID: tc.userID, DomainID: tc.domainID, DomainUserID: validID}
repoCall := boot.On("RetrieveByID", context.Background(), tc.domainID, tc.id).Return(c, tc.retrieveErr)
sdkCall := sdk.On("ConnectClient", mock.Anything, mock.Anything, []string{"Publish", "Subscribe"}, mock.Anything, tc.token).Return(tc.connectErr)
repoCall1 := boot.On("ChangeState", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(tc.stateErr)
+4 -4
View File
@@ -6,18 +6,18 @@ package bootstrap
import "strconv"
const (
// Inactive Client is created, but not able to exchange messages using Magistrala.
// Inactive Client is created, but not able to exchange messages using SuperMQ.
Inactive State = iota
// Active Client is created, configured, and whitelisted.
Active
)
// State represents corresponding Magistrala Client state. The possible Config States
// State represents corresponding SuperMQ Client state. The possible Config States
// as well as description of what that State represents are given in the table:
// | State | What it means |
// |----------+--------------------------------------------------------------------------------|
// | Inactive | Client is created, but isn't able to communicate over Magistrala |
// | Active | Client is able to communicate using Magistrala |.
// | Inactive | Client is created, but isn't able to communicate over SuperMQ |
// | Active | Client is able to communicate using SuperMQ |.
type State int
// String returns string representation of State.
+5 -5
View File
@@ -1,12 +1,12 @@
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
// Package tracing provides tracing instrumentation for Magistrala Users service.
// Package tracing provides tracing instrumentation for SuperMQ Users service.
//
// This package provides tracing middleware for Magistrala Users service.
// This package provides tracing middleware for SuperMQ Users service.
// It can be used to trace incoming requests and add tracing capabilities to
// Magistrala Users service.
// SuperMQ Users service.
//
// For more details about tracing instrumentation for Magistrala messaging refer
// to the documentation at https://docs.magistrala.abstractmachines.fr/tracing/.
// For more details about tracing instrumentation for SuperMQ messaging refer
// to the documentation at https://docs.supermq.abstractmachines.fr/tracing/.
package tracing
+10 -10
View File
@@ -6,8 +6,8 @@ package tracing
import (
"context"
"github.com/absmach/magistrala/bootstrap"
mgauthn "github.com/absmach/magistrala/pkg/authn"
"github.com/absmach/supermq/bootstrap"
smqauthn "github.com/absmach/supermq/pkg/authn"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
@@ -25,7 +25,7 @@ func New(svc bootstrap.Service, tracer trace.Tracer) bootstrap.Service {
}
// Add traces the "Add" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) Add(ctx context.Context, session mgauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
func (tm *tracingMiddleware) Add(ctx context.Context, session smqauthn.Session, token string, cfg bootstrap.Config) (bootstrap.Config, error) {
ctx, span := tm.tracer.Start(ctx, "svc_register_user", trace.WithAttributes(
attribute.String("client_id", cfg.ClientID),
attribute.String("domain_id ", cfg.DomainID),
@@ -40,7 +40,7 @@ func (tm *tracingMiddleware) Add(ctx context.Context, session mgauthn.Session, t
}
// View traces the "View" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) View(ctx context.Context, session mgauthn.Session, id string) (bootstrap.Config, error) {
func (tm *tracingMiddleware) View(ctx context.Context, session smqauthn.Session, id string) (bootstrap.Config, error) {
ctx, span := tm.tracer.Start(ctx, "svc_view_user", trace.WithAttributes(
attribute.String("id", id),
))
@@ -50,7 +50,7 @@ func (tm *tracingMiddleware) View(ctx context.Context, session mgauthn.Session,
}
// Update traces the "Update" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) Update(ctx context.Context, session mgauthn.Session, cfg bootstrap.Config) error {
func (tm *tracingMiddleware) Update(ctx context.Context, session smqauthn.Session, cfg bootstrap.Config) error {
ctx, span := tm.tracer.Start(ctx, "svc_update_user", trace.WithAttributes(
attribute.String("name", cfg.Name),
attribute.String("content", cfg.Content),
@@ -63,7 +63,7 @@ func (tm *tracingMiddleware) Update(ctx context.Context, session mgauthn.Session
}
// UpdateCert traces the "UpdateCert" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) UpdateCert(ctx context.Context, session mgauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
func (tm *tracingMiddleware) UpdateCert(ctx context.Context, session smqauthn.Session, clientID, clientCert, clientKey, caCert string) (bootstrap.Config, error) {
ctx, span := tm.tracer.Start(ctx, "svc_update_cert", trace.WithAttributes(
attribute.String("client_id", clientID),
))
@@ -73,7 +73,7 @@ func (tm *tracingMiddleware) UpdateCert(ctx context.Context, session mgauthn.Ses
}
// UpdateConnections traces the "UpdateConnections" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) UpdateConnections(ctx context.Context, session mgauthn.Session, token, id string, connections []string) error {
func (tm *tracingMiddleware) UpdateConnections(ctx context.Context, session smqauthn.Session, token, id string, connections []string) error {
ctx, span := tm.tracer.Start(ctx, "svc_update_connections", trace.WithAttributes(
attribute.String("id", id),
attribute.StringSlice("connections", connections),
@@ -84,7 +84,7 @@ func (tm *tracingMiddleware) UpdateConnections(ctx context.Context, session mgau
}
// List traces the "List" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) List(ctx context.Context, session mgauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
func (tm *tracingMiddleware) List(ctx context.Context, session smqauthn.Session, filter bootstrap.Filter, offset, limit uint64) (bootstrap.ConfigsPage, error) {
ctx, span := tm.tracer.Start(ctx, "svc_list_users", trace.WithAttributes(
attribute.Int64("offset", int64(offset)),
attribute.Int64("limit", int64(limit)),
@@ -95,7 +95,7 @@ func (tm *tracingMiddleware) List(ctx context.Context, session mgauthn.Session,
}
// Remove traces the "Remove" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) Remove(ctx context.Context, session mgauthn.Session, id string) error {
func (tm *tracingMiddleware) Remove(ctx context.Context, session smqauthn.Session, id string) error {
ctx, span := tm.tracer.Start(ctx, "svc_remove_user", trace.WithAttributes(
attribute.String("id", id),
))
@@ -117,7 +117,7 @@ func (tm *tracingMiddleware) Bootstrap(ctx context.Context, externalKey, externa
}
// ChangeState traces the "ChangeState" operation of the wrapped bootstrap.Service.
func (tm *tracingMiddleware) ChangeState(ctx context.Context, session mgauthn.Session, token, id string, state bootstrap.State) error {
func (tm *tracingMiddleware) ChangeState(ctx context.Context, session smqauthn.Session, token, id string, state bootstrap.State) error {
ctx, span := tm.tracer.Start(ctx, "svc_change_state", trace.WithAttributes(
attribute.String("id", id),
attribute.String("state", state.String()),
+82 -82
View File
@@ -1,23 +1,23 @@
# Certs Service
Issues certificates for clients. `Certs` service can create certificates to be used when `Magistrala` is deployed to support mTLS.
Issues certificates for clients. `Certs` service can create certificates to be used when `SuperMQ` is deployed to support mTLS.
Certificate service can create certificates using PKI mode - where certificates issued by PKI, when you deploy `Vault` as PKI certificate management `cert` service will proxy requests to `Vault` previously checking access rights and saving info on successfully created certificate.
## PKI mode
When `MG_CERTS_VAULT_HOST` is set it is presumed that `Vault` is installed and `certs` service will issue certificates using `Vault` API.
When `SMQ_CERTS_VAULT_HOST` is set it is presumed that `Vault` is installed and `certs` service will issue certificates using `Vault` API.
First you'll need to set up `Vault`.
To setup `Vault` follow steps in [Build Your Own Certificate Authority (CA)](https://learn.hashicorp.com/tutorials/vault/pki-engine).
For lab purposes you can use docker-compose and script for setting up PKI in [https://github.com/absmach/magistrala/blob/main/docker/addons/vault/README.md](https://github.com/absmach/magistrala/blob/main/docker/addons/vault/README.md)
For lab purposes you can use docker-compose and script for setting up PKI in [https://github.com/absmach/supermq/blob/main/docker/addons/vault/README.md](https://github.com/absmach/supermq/blob/main/docker/addons/vault/README.md)
```bash
MG_CERTS_VAULT_HOST=<https://vault-domain:8200>
MG_CERTS_VAULT_NAMESPACE=<vault_namespace>
MG_CERTS_VAULT_APPROLE_ROLEID=<vault_approle_roleid>
MG_CERTS_VAULT_APPROLE_SECRET=<vault_approle_sceret>
MG_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH=<vault_clients_certs_pki_path>
MG_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME=<vault_clients_certs_issue_role_name>
SMQ_CERTS_VAULT_HOST=<https://vault-domain:8200>
SMQ_CERTS_VAULT_NAMESPACE=<vault_namespace>
SMQ_CERTS_VAULT_APPROLE_ROLEID=<vault_approle_roleid>
SMQ_CERTS_VAULT_APPROLE_SECRET=<vault_approle_sceret>
SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH=<vault_clients_certs_pki_path>
SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME=<vault_clients_certs_issue_role_name>
```
The certificates can also be revoked using `certs` service. To revoke a certificate you need to provide `client_id` of the client for which the certificate was issued.
@@ -30,53 +30,53 @@ curl -s -S -X DELETE http://localhost:9019/certs/revoke -H "Authorization: Beare
The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.
| Variable | Description | Default |
| :----------------------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| MG_CERTS_LOG_LEVEL | Log level for the Certs (debug, info, warn, error) | info |
| MG_CERTS_HTTP_HOST | Service Certs host | "" |
| MG_CERTS_HTTP_PORT | Service Certs port | 9019 |
| MG_CERTS_HTTP_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| MG_CERTS_HTTP_SERVER_KEY | Path to the PEM encoded server key file | "" |
| MG_AUTH_GRPC_URL | Auth service gRPC URL | [localhost:8181](localhost:8181) |
| MG_AUTH_GRPC_TIMEOUT | Auth service gRPC request timeout in seconds | 1s |
| MG_AUTH_GRPC_CLIENT_CERT | Path to the PEM encoded auth service gRPC client certificate file | "" |
| MG_AUTH_GRPC_CLIENT_KEY | Path to the PEM encoded auth service gRPC client key file | "" |
| MG_AUTH_GRPC_SERVER_CERTS | Path to the PEM encoded auth server gRPC server trusted CA certificate file | "" |
| MG_CERTS_SIGN_CA_PATH | Path to the PEM encoded CA certificate file | ca.crt |
| MG_CERTS_SIGN_CA_KEY_PATH | Path to the PEM encoded CA key file | ca.key |
| MG_CERTS_VAULT_HOST | Vault host | http://vault:8200 |
| MG_CERTS_VAULT_NAMESPACE | Vault namespace in which pki is present | magistrala |
| MG_CERTS_VAULT_APPROLE_ROLEID | Vault AppRole auth RoleID | magistrala |
| MG_CERTS_VAULT_APPROLE_SECRET | Vault AppRole auth Secret | magistrala |
| MG_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH | Vault PKI path for issuing Clients Certificates | pki_int |
| MG_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME | Vault PKI Role Name for issuing Clients Certificates | magistrala_clients_certs |
| MG_CERTS_DB_HOST | Database host | localhost |
| MG_CERTS_DB_PORT | Database port | 5432 |
| MG_CERTS_DB_PASS | Database password | magistrala |
| MG_CERTS_DB_USER | Database user | magistrala |
| MG_CERTS_DB_NAME | Database name | certs |
| MG_CERTS_DB_SSL_MODE | Database SSL mode | disable |
| MG_CERTS_DB_SSL_CERT | Database SSL certificate | "" |
| MG_CERTS_DB_SSL_KEY | Database SSL key | "" |
| MG_CERTS_DB_SSL_ROOT_CERT | Database SSL root certificate | "" |
| MG_CLIENTS_URL | Clients service URL | [localhost:9000](localhost:9000) |
| MG_JAEGER_URL | Jaeger server URL | [http://localhost:4318/v1/traces](http://localhost:4318//v1/traces) |
| MG_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| MG_SEND_TELEMETRY | Send telemetry to magistrala call home server | true |
| MG_CERTS_INSTANCE_ID | Service instance ID | "" |
| Variable | Description | Default |
| :------------------------------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| SMQ_CERTS_LOG_LEVEL | Log level for the Certs (debug, info, warn, error) | info |
| SMQ_CERTS_HTTP_HOST | Service Certs host | "" |
| SMQ_CERTS_HTTP_PORT | Service Certs port | 9019 |
| SMQ_CERTS_HTTP_SERVER_CERT | Path to the PEM encoded server certificate file | "" |
| SMQ_CERTS_HTTP_SERVER_KEY | Path to the PEM encoded server key file | "" |
| SMQ_AUTH_GRPC_URL | Auth service gRPC URL | [localhost:8181](localhost:8181) |
| SMQ_AUTH_GRPC_TIMEOUT | Auth service gRPC request timeout in seconds | 1s |
| SMQ_AUTH_GRPC_CLIENT_CERT | Path to the PEM encoded auth service gRPC client certificate file | "" |
| SMQ_AUTH_GRPC_CLIENT_KEY | Path to the PEM encoded auth service gRPC client key file | "" |
| SMQ_AUTH_GRPC_SERVER_CERTS | Path to the PEM encoded auth server gRPC server trusted CA certificate file | "" |
| SMQ_CERTS_SIGN_CA_PATH | Path to the PEM encoded CA certificate file | ca.crt |
| SMQ_CERTS_SIGN_CA_KEY_PATH | Path to the PEM encoded CA key file | ca.key |
| SMQ_CERTS_VAULT_HOST | Vault host | http://vault:8200 |
| SMQ_CERTS_VAULT_NAMESPACE | Vault namespace in which pki is present | supermq |
| SMQ_CERTS_VAULT_APPROLE_ROLEID | Vault AppRole auth RoleID | supermq |
| SMQ_CERTS_VAULT_APPROLE_SECRET | Vault AppRole auth Secret | supermq |
| SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH | Vault PKI path for issuing Clients Certificates | pki_int |
| SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME | Vault PKI Role Name for issuing Clients Certificates | supermq_clients_certs |
| SMQ_CERTS_DB_HOST | Database host | localhost |
| SMQ_CERTS_DB_PORT | Database port | 5432 |
| SMQ_CERTS_DB_PASS | Database password | supermq |
| SMQ_CERTS_DB_USER | Database user | supermq |
| SMQ_CERTS_DB_NAME | Database name | certs |
| SMQ_CERTS_DB_SSL_MODE | Database SSL mode | disable |
| SMQ_CERTS_DB_SSL_CERT | Database SSL certificate | "" |
| SMQ_CERTS_DB_SSL_KEY | Database SSL key | "" |
| SMQ_CERTS_DB_SSL_ROOT_CERT | Database SSL root certificate | "" |
| SMQ_CLIENTS_URL | Clients service URL | [localhost:9000](localhost:9000) |
| SMQ_JAEGER_URL | Jaeger server URL | [http://localhost:4318/v1/traces](http://localhost:4318//v1/traces) |
| SMQ_JAEGER_TRACE_RATIO | Jaeger sampling ratio | 1.0 |
| SMQ_SEND_TELEMETRY | Send telemetry to supermq call home server | true |
| SMQ_CERTS_INSTANCE_ID | Service instance ID | "" |
## Deployment
The service is distributed as Docker container. Check the [`certs`](https://github.com/absmach/magistrala/blob/main/docker/addons/bootstrap/docker-compose.yml) service section in docker-compose file to see how the service is deployed.
The service is distributed as Docker container. Check the [`certs`](https://github.com/absmach/supermq/blob/main/docker/addons/bootstrap/docker-compose.yml) service section in docker-compose file to see how the service is deployed.
Running this service outside of container requires working instance of the auth service, clients service, postgres database, vault and Jaeger server.
To start the service outside of the container, execute the following shell script:
```bash
# download the latest version of the service
git clone https://github.com/absmach/magistrala
git clone https://github.com/absmach/supermq
cd magistrala
cd supermq
# compile the certs
make certs
@@ -85,45 +85,45 @@ make certs
make install
# set the environment variables and run the service
MG_CERTS_LOG_LEVEL=info \
MG_CERTS_HTTP_HOST=localhost \
MG_CERTS_HTTP_PORT=9019 \
MG_CERTS_HTTP_SERVER_CERT="" \
MG_CERTS_HTTP_SERVER_KEY="" \
MG_AUTH_GRPC_URL=localhost:8181 \
MG_AUTH_GRPC_TIMEOUT=1s \
MG_AUTH_GRPC_CLIENT_CERT="" \
MG_AUTH_GRPC_CLIENT_KEY="" \
MG_AUTH_GRPC_SERVER_CERTS="" \
MG_CERTS_SIGN_CA_PATH=ca.crt \
MG_CERTS_SIGN_CA_KEY_PATH=ca.key \
MG_CERTS_VAULT_HOST=http://vault:8200 \
MG_CERTS_VAULT_NAMESPACE=magistrala \
MG_CERTS_VAULT_APPROLE_ROLEID=magistrala \
MG_CERTS_VAULT_APPROLE_SECRET=magistrala \
MG_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH=pki_int \
MG_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME=magistrala_clients_certs \
MG_CERTS_DB_HOST=localhost \
MG_CERTS_DB_PORT=5432 \
MG_CERTS_DB_PASS=magistrala \
MG_CERTS_DB_USER=magistrala \
MG_CERTS_DB_NAME=certs \
MG_CERTS_DB_SSL_MODE=disable \
MG_CERTS_DB_SSL_CERT="" \
MG_CERTS_DB_SSL_KEY="" \
MG_CERTS_DB_SSL_ROOT_CERT="" \
MG_CLIENTS_URL=localhost:9000 \
MG_JAEGER_URL=http://localhost:14268/api/traces \
MG_JAEGER_TRACE_RATIO=1.0 \
MG_SEND_TELEMETRY=true \
MG_CERTS_INSTANCE_ID="" \
$GOBIN/magistrala-certs
SMQ_CERTS_LOG_LEVEL=info \
SMQ_CERTS_HTTP_HOST=localhost \
SMQ_CERTS_HTTP_PORT=9019 \
SMQ_CERTS_HTTP_SERVER_CERT="" \
SMQ_CERTS_HTTP_SERVER_KEY="" \
SMQ_AUTH_GRPC_URL=localhost:8181 \
SMQ_AUTH_GRPC_TIMEOUT=1s \
SMQ_AUTH_GRPC_CLIENT_CERT="" \
SMQ_AUTH_GRPC_CLIENT_KEY="" \
SMQ_AUTH_GRPC_SERVER_CERTS="" \
SMQ_CERTS_SIGN_CA_PATH=ca.crt \
SMQ_CERTS_SIGN_CA_KEY_PATH=ca.key \
SMQ_CERTS_VAULT_HOST=http://vault:8200 \
SMQ_CERTS_VAULT_NAMESPACE=supermq \
SMQ_CERTS_VAULT_APPROLE_ROLEID=supermq \
SMQ_CERTS_VAULT_APPROLE_SECRET=supermq \
SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_PATH=pki_int \
SMQ_CERTS_VAULT_CLIENTS_CERTS_PKI_ROLE_NAME=supermq_clients_certs \
SMQ_CERTS_DB_HOST=localhost \
SMQ_CERTS_DB_PORT=5432 \
SMQ_CERTS_DB_PASS=supermq \
SMQ_CERTS_DB_USER=supermq \
SMQ_CERTS_DB_NAME=certs \
SMQ_CERTS_DB_SSL_MODE=disable \
SMQ_CERTS_DB_SSL_CERT="" \
SMQ_CERTS_DB_SSL_KEY="" \
SMQ_CERTS_DB_SSL_ROOT_CERT="" \
SMQ_CLIENTS_URL=localhost:9000 \
SMQ_JAEGER_URL=http://localhost:14268/api/traces \
SMQ_JAEGER_TRACE_RATIO=1.0 \
SMQ_SEND_TELEMETRY=true \
SMQ_CERTS_INSTANCE_ID="" \
$GOBIN/supermq-certs
```
Setting `MG_CERTS_HTTP_SERVER_CERT` and `MG_CERTS_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `SMQ_CERTS_HTTP_SERVER_CERT` and `SMQ_CERTS_HTTP_SERVER_KEY` will enable TLS against the service. The service expects a file in PEM format for both the certificate and the key.
Setting `MG_AUTH_GRPC_CLIENT_CERT` and `MG_AUTH_GRPC_CLIENT_KEY` will enable TLS against the auth service. The service expects a file in PEM format for both the certificate and the key. Setting `MG_AUTH_GRPC_SERVER_CERTS` will enable TLS against the auth service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
Setting `SMQ_AUTH_GRPC_CLIENT_CERT` and `SMQ_AUTH_GRPC_CLIENT_KEY` will enable TLS against the auth service. The service expects a file in PEM format for both the certificate and the key. Setting `SMQ_AUTH_GRPC_SERVER_CERTS` will enable TLS against the auth service trusting only those CAs that are provided. The service expects a file in PEM format of trusted CAs.
## Usage
For more information about service capabilities and its usage, please check out the [Certs section](https://docs.magistrala.abstractmachines.fr/certs/).
For more information about service capabilities and its usage, please check out the [Certs section](https://docs.supermq.abstractmachines.fr/certs/).
+3 -3
View File
@@ -6,9 +6,9 @@ package api
import (
"context"
"github.com/absmach/magistrala/certs"
"github.com/absmach/magistrala/pkg/apiutil"
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/supermq/certs"
"github.com/absmach/supermq/pkg/apiutil"
"github.com/absmach/supermq/pkg/errors"
"github.com/go-kit/kit/endpoint"
)
+20 -20
View File
@@ -13,16 +13,16 @@ import (
"testing"
"time"
"github.com/absmach/magistrala/certs"
httpapi "github.com/absmach/magistrala/certs/api"
"github.com/absmach/magistrala/certs/mocks"
"github.com/absmach/magistrala/internal/testsutil"
mglog "github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/apiutil"
mgauthn "github.com/absmach/magistrala/pkg/authn"
authnmocks "github.com/absmach/magistrala/pkg/authn/mocks"
"github.com/absmach/magistrala/pkg/errors"
svcerr "github.com/absmach/magistrala/pkg/errors/service"
"github.com/absmach/supermq/certs"
httpapi "github.com/absmach/supermq/certs/api"
"github.com/absmach/supermq/certs/mocks"
"github.com/absmach/supermq/internal/testsutil"
smqlog "github.com/absmach/supermq/logger"
"github.com/absmach/supermq/pkg/apiutil"
smqauthn "github.com/absmach/supermq/pkg/authn"
authnmocks "github.com/absmach/supermq/pkg/authn/mocks"
"github.com/absmach/supermq/pkg/errors"
svcerr "github.com/absmach/supermq/pkg/errors/service"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
@@ -68,7 +68,7 @@ func (tr testRequest) make() (*http.Response, error) {
func newCertServer() (*httptest.Server, *mocks.Service, *authnmocks.Authentication) {
svc := new(mocks.Service)
logger := mglog.NewMock()
logger := smqlog.NewMock()
authn := new(authnmocks.Authentication)
mux := httpapi.MakeHandler(svc, authn, logger, "")
@@ -86,7 +86,7 @@ func TestIssueCert(t *testing.T) {
desc string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
contentType string
clientID string
ttl string
@@ -224,7 +224,7 @@ func TestIssueCert(t *testing.T) {
body: strings.NewReader(tc.request),
}
if tc.token == valid {
tc.session = mgauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
tc.session = smqauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("IssueCert", mock.Anything, tc.domainID, tc.token, tc.clientID, tc.ttl).Return(tc.svcRes, tc.svcErr)
@@ -252,10 +252,10 @@ func TestViewCert(t *testing.T) {
desc string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
serialID string
status int
authenticateRes mgauthn.Session
authenticateRes smqauthn.Session
authenticateErr error
svcRes certs.Cert
svcErr error
@@ -310,7 +310,7 @@ func TestViewCert(t *testing.T) {
token: tc.token,
}
if tc.token == valid {
tc.session = mgauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
tc.session = smqauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("ViewCert", mock.Anything, tc.serialID).Return(tc.svcRes, tc.svcErr)
@@ -338,7 +338,7 @@ func TestRevokeCert(t *testing.T) {
desc string
domainID string
token string
session mgauthn.Session
session smqauthn.Session
serialID string
status int
authenticateErr error
@@ -403,7 +403,7 @@ func TestRevokeCert(t *testing.T) {
token: tc.token,
}
if tc.token == valid {
tc.session = mgauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
tc.session = smqauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("RevokeCert", mock.Anything, tc.domainID, tc.token, tc.serialID).Return(tc.svcRes, tc.svcErr)
@@ -432,7 +432,7 @@ func TestListSerials(t *testing.T) {
desc string
token string
domainID string
session mgauthn.Session
session smqauthn.Session
clientID string
revoked string
offset uint64
@@ -646,7 +646,7 @@ func TestListSerials(t *testing.T) {
token: tc.token,
}
if tc.token == valid {
tc.session = mgauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
tc.session = smqauthn.Session{DomainUserID: validID, UserID: validID, DomainID: validID}
}
authCall := auth.On("Authenticate", mock.Anything, tc.token).Return(tc.session, tc.authenticateErr)
svcCall := svc.On("ListSerials", mock.Anything, tc.clientID, certs.PageMetadata{Revoked: tc.revoked, Offset: tc.offset, Limit: tc.limit}).Return(tc.svcRes, tc.svcErr)
+1 -1
View File
@@ -10,7 +10,7 @@ import (
"log/slog"
"time"
"github.com/absmach/magistrala/certs"
"github.com/absmach/supermq/certs"
)
var _ certs.Service = (*loggingMiddleware)(nil)
+1 -1
View File
@@ -9,7 +9,7 @@ import (
"context"
"time"
"github.com/absmach/magistrala/certs"
"github.com/absmach/supermq/certs"
"github.com/go-kit/kit/metrics"
)

Some files were not shown because too many files have changed in this diff Show More