Code Monkey home page Code Monkey logo

license's Introduction

Mainflux Licensing Service

coverage build

Licensing service

Concepts

License is used to validate a service on startup. License entity looks like this:

type License struct {
	ID        string                 `json:"id"`
	Key       string                 `json:"key"`
	Issuer    string                 `json:"issuer"`
	DeviceID  string                 `json:"device_id"`
	Active    bool                   `json:"active"`
	CreatedAt time.Time              `json:"created_at"`
	ExpiresAt time.Time              `json:"expires_at"`
	UpdatedBy string                 `json:"updated_by"`
	UpdatedAt time.Time              `json:"updated_at"`
	Services  []string               `json:"services"`
	Plan      map[string]interface{} `json:"plan"`
	Signature []byte                 `json:"signature"`
}

Please note that some of these fields are not used at the moment and are hare for the future use.

The licensing flow has two parts: service and agent.

Licensing service

Licensing service provides basic CRUD operations over License.

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
MF_LICENSE_LOG_LEVEL License service log level error
MF_LICENSE_DB_HOST DB host localhost
MF_LICENSE_DB_PORT DB port 5432
MF_LICENSE_DB_USER DB user mainflux
MF_LICENSE_DB_PASS DB pass mainflux
MF_LICENSE_DB DB name license
MF_LICENSE_DB_SSL_MODE DB SSL mode disable
MF_LICENSE_DB_SSL_CERT DB SSL cert in PEM
MF_LICENSE_DB_SSL_KEY DB SSL key
MF_LICENSE_DB_SSL_ROOT_CERT DB SSL root cert
MF_LICENSE_CLIENT_TLS Client TLS false
MF_LICENSE_CA_CERTS gRPC CA cert
MF_LICENSE_PORT service HTTP port 8111
MF_LICENSE_SERVER_CERT server TLS cert
MF_LICENSE_SERVER_KEY server TLS cert key
MF_JAEGER_URL tracing URL
MF_AUTH_URL Auth service URL localhost:8181
MF_AUTH_TIMEOUT Auth service call timeout 1

Licensing Agent

The agent is an executable that's running on local machine and is used for license validation and synchronization with the service.

The agent 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
MF_LICENSE_LOG_LEVEL Agent log level "error"
MF_LICENSE_SERVICE_URL License service URL "http://localhost:8111/licenses/devices"
LICENSE_FILE File to store license in "./license"
MF_LICENSE_CLIENT_TLS HTTP client for License service "false"
MF_LICENSE_AGENT_CERT Agent TLS cert
MF_AGENT_SERVER_KEY Agen TLS cert key
MF_AGENT_PORT Agent port "3000"
MF_AGENT_LOAD_RETRY_SECONDS Retry period in seconds to wait between two sync calls to service "60"

The Agent fetches the License using its ID, and exposes HTTP API for validation. You can se the License validation flow on the diagram below:

diagram

license's People

Contributors

dborovcanin avatar drasko avatar hoanga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

license's Issues

Add License Agent client lib

Add client for the License Agent. This client is meant to be invoked as a lib and will receive a custom handler that will act on the validation response.

Introduce License client

The license client is an HTTP client for the licensing service. Its initial implementation should provide basic communication with License service and License validation. In the future, the licensing client will be extended to take control of services.

Synchronize Agent with cloud service

If there is no License stored locally, the Agent will loop until it gets it from the cloud. Once the License is loaded successfully, the Agent is ready to accept validation requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.