https://github.com/apinf/emq-rest-api
A REST API for EMQ user and ACL rule management, built with Sails.js
https://github.com/apinf/emq-rest-api
Last synced: 8 months ago
JSON representation
A REST API for EMQ user and ACL rule management, built with Sails.js
- Host: GitHub
- URL: https://github.com/apinf/emq-rest-api
- Owner: apinf
- License: mit
- Created: 2017-02-08T09:31:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-20T23:19:53.000Z (about 9 years ago)
- Last Synced: 2025-01-21T09:28:02.254Z (over 1 year ago)
- Language: JavaScript
- Size: 140 KB
- Stars: 0
- Watchers: 15
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EMQ API (Sails)
A REST API for managing EMQ Users and ACL Rules, built with [Sails.js](http://sailsjs.org) (for multiple database support)
# Endpoints
Supported all default [blueprints](http://sailsjs.com/documentation/reference/blueprint-api)
### EMQ-USER
- `POST` - `/emq-user`
- AUTH (Basic)
- admin `username`
- admin `password`
- DATA
- emq-user `username`
- emq-user `password`
- is_superuser
- `GET (all)` - `/emq-user`
- AUTH (Basic)
- admin `username`
- admin `password`
- `GET (one)` - `/emq-user/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- `DELETE (one)` - `/emq-user/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- `PUT (one)` - `/emq-user/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- DATA
- emq-user `username`
- emq-user `password`
- is_superuser
- ... and other that are less common and basically not used
### EMQ_ACL
- `POST` - `/emq-acl`
- AUTH (Basic)
- admin `username`
- admin `password`
- DATA
- `allow` - integer
- `ipaddr` - string
- `username` - string
- `clientid` - string
- `access` - integer
- `topic` - string
- `GET (all)` - `/emq-acl`
- AUTH (Basic)
- admin `username`
- admin `password`
- `GET (one)` - `/emq-acl/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- `DELETE (one)` - `/emq-acl/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- `PUT (one)` - `/emq-acl/:`
- AUTH (Basic)
- admin `username`
- admin `password`
- DATA
- `allow` - integer
- `ipaddr` - string
- `username` - string
- `clientid` - string
- `access` - integer
- `topic` - string
# Development
To set up a local development environment, make sure you have Sails installed globally (`npm install -g sailsjs`). Then:
1. Clone this repository
2. Open the repository directory in your terminal
3. Update PostgreSQL credentials in `config/connections.js`
4. Run the following command, which creates an admin user:
```
sails_permissions__adminUsername="admin" sails_permissions__adminPassword="test12345" sails lift
```
Once Sails has lifted, you can make requests to the REST API.
Be sure to include your Base 64 encoded username and password in the request header:
```
Authorization: Basic
```
E.g. with curl:
```
curl -H "Authorization: Basic YWRtaW46dGVzdDEyMzQ1" -X POST "http://localhost:1337/emq-user" -d "username=friendly&password=secretpassword"
```