-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
68 lines (62 loc) · 1.38 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const macl = require('./index.js');
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`);
//console.log(JSON.stringify(acl, null, ' '));
/*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'
}
]
}));
*/
console.log(macl.stringify({
patterns: [
{
perm: 'read',
topic: 'test'
}
]
}));