Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hobbyquaker/mosquitto-acl-parser
Parse and Stringify Mosquitto ACLs
https://github.com/hobbyquaker/mosquitto-acl-parser
acl mosquitto mqtt parse stringify
Last synced: about 2 months ago
JSON representation
Parse and Stringify Mosquitto ACLs
- Host: GitHub
- URL: https://github.com/hobbyquaker/mosquitto-acl-parser
- Owner: hobbyquaker
- License: mit
- Created: 2017-05-12T19:35:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-12T19:50:50.000Z (over 7 years ago)
- Last Synced: 2024-10-28T07:11:07.395Z (2 months ago)
- Topics: acl, mosquitto, mqtt, parse, stringify
- Language: JavaScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mosquitto-acl-parser
[![NPM version](https://badge.fury.io/js/mosquitto-acl-parser.svg)](http://badge.fury.io/js/mosquitto-acl-parser)
[![Dependency Status](https://img.shields.io/gemnasium/hobbyquaker/mosquitto-acl-parser.svg?maxAge=2592000)](https://gemnasium.com/github.com/hobbyquaker/mosquitto-acl-parser)
[![Build Status](https://travis-ci.org/hobbyquaker/mosquitto-acl-parser.svg?branch=master)](https://travis-ci.org/hobbyquaker/mosquitto-acl-parser)
[![Coverage Status](https://coveralls.io/repos/github/hobbyquaker/mosquitto-acl-parser/badge.svg?branch=master)](https://coveralls.io/github/hobbyquaker/mosquitto-acl-parser?branch=master)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
[![License][mit-badge]][mit-url]> Parse and Stringify Mosquitto ACLs
This tiny module parses [Mosquitto](https://mosquitto.org/) ACLs into a Javascript object and stringifies objects back
into a ACL string.## Usage
`npm install mosquitto-acl-parser`
### .parse(string)
```Javascript
const macl = require('mosquitto-acl-parser');const acl = macl.parse(`# This affects access control for clients with no username.
topic read $SYS/## This only affects clients with username "roger".
user roger
topic foo/bar# This affects all clients.
pattern write $SYS/broker/connection/%c/state`);
````acl` contains then...
```JSON
{
"topics": [
{
"perm": "read",
"topic": "$SYS/#"
}
],
"users": {
"roger": [
{
"perm": "readwrite",
"topic": "foo/bar"
}
]
},
"patterns": [
{
"perm": "write",
"topic": "$SYS/broker/connection/%c/state"
}
]
}
```### .stringify(acl)
```Javascript
const macl = require('mosquitto-acl-parser');console.log(macl.stringify({
topics: [
{
perm: 'read',
topic: 'everyone/can/read '
},
{
perm: 'readwrite',
topic: 'everyone/can/readwrite'
}
],
users: {
user1: [
{
perm: 'read',
topic: 'user1/can/read'
},
{
perm: 'readwrite',
topic: 'user1/can/readwrite'
}
],
user2: [
{
perm: 'read',
topic: 'user2/can/read'
},
{
perm: 'readwrite',
topic: 'user2/can/readwrite'
}
]
},
patterns: [
{
perm: 'read',
topic: 'pattern/%u/can/read'
},
{
perm: 'readwrite',
topic: 'pattern/%u/can/readwrite'
}
]
}));
```Outputs...
```
# created by mosquitto-acl-parsertopic read everyone/can/read
topic readwrite everyone/can/readwriteuser user1
topic read user1/can/read
topic readwrite user1/can/readwriteuser user2
topic read user2/can/read
topic readwrite user2/can/readwritepattern read pattern/%u/can/read
pattern readwrite pattern/%u/can/readwrite
```## License
MIT (c) 2017 [Sebastian Raff](https://github.com/hobbyquaker)
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE