Skip to content

Commit

Permalink
Check block to be separate property listing topics
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Sep 11, 2016
1 parent 54bffca commit c62ba21
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 289 deletions.
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# mqlobber-access-control   [![Build Status](https://travis-ci.org/davedoesdev/mqlobber-access-control.png)](https://travis-ci.org/davedoesdev/mqlobber-access-control) [![Coverage Status](https://coveralls.io/repos/davedoesdev/mqlobber-access-control/badge.png?branch=master&service=github)](https://coveralls.io/r/davedoesdev/mqlobber-access-control?branch=master) [![NPM version](https://badge.fury.io/js/mqlobber-access-control.png)](http://badge.fury.io/js/mqlobber-access-control)

Access control for [mqlobber](https://github.com/davedoesdev/mqlobber) message
queues. Specify to which topics clients can (and can't) subscribe and publish.
queues. Specify to which topics clients can (and can't) subscribe, publish and
receive.

The API is described [here](#api).

Expand Down Expand Up @@ -210,7 +211,8 @@ Coveralls page is [here](https://coveralls.io/r/davedoesdev/mqlobber-access-cont
## AccessControl(options)
> Create a new `AccessControl` object for applying access control on publish
and subscribe requests to [`MQlobberServer`](https://github.com/davedoesdev/mqlobber#mqlobberserverfsq-stream-options) objects.
and subscribe requests to [`MQlobberServer`](https://github.com/davedoesdev/mqlobber#mqlobberserverfsq-stream-options) objects and messages delivered to
clients.
Calls [`reset`](#accesscontrolprototyperesetoptions) after creating the object.
Expand All @@ -225,20 +227,23 @@ Calls [`reset`](#accesscontrolprototyperesetoptions) after creating the object.
## AccessControl.prototype.reset(options)
> Reset the access control applied by this object to client publish and subscribe
requests on attached [`MQlobberServer`](https://github.com/davedoesdev/mqlobber#mqlobberserverfsq-stream-options) objects.
requests on attached [`MQlobberServer`](https://github.com/davedoesdev/mqlobber#mqlobberserverfsq-stream-options) objects and messages delivered to clients.
**Parameters:**
- `{Object} options` Specifies to which topics clients should be allowed and disallowed to publish and subscribe messages. It supports the following properties:
- `{Object} options` Specifies to which topics clients should be allowed and disallowed to publish, subscribe and receive messages. It supports the following properties:
- `{Object} [publish]` Allowed and disallowed topics for publish requests, with the following properties:
- `{Array} [allow]` Clients can publish messages to these topics.
- `{Array} [disallow]` Clients cannot publish messages to these topics.
- `{Object} [subscribe]` Allowed and disallowed topics for subscribe requests, with the following properties:
- `{Array} [allow]` Clients can subscribe to messages published to these topics.
- `{Array} [disallow]` Clients cannot subscribe to messages published to these topics.
- `{Boolean} [block]` Whether to prevent messages with topics matched by `disallow` being delivered to clients. This is useful if `allow` is a superset of `disallow` but you don't want messages matching `disallow` sent to clients. Defaults to `false`.
- `{Array} [block]` Clients cannot receive messages published to these topics.
This is useful if `subscribe.allow` is a superset of `subscribe.disallow` but you don't want messages matching (a subset of) `subscribe.disallow` sent to clients.
Topics are the same as [`mqlobber` topics](https://github.com/davedoesdev/mqlobber#mqlobberclientprototypesubscribetopic-handler-cb) and [`qlobber-fsq` topics](
https://github.com/davedoesdev/qlobber-fsq#qlobberfsqprototypesubscribetopic-handler-cb). They're split into words using `.` as the separator. You can use `*`
to match exactly one word in a topic or `#` to match zero or more words.
Expand All @@ -264,12 +269,12 @@ Access control is only applied where topics are specified.
> Start applying access control to a [`MQlobberServer`](https://github.com/davedoesdev/mqlobber#mqlobberserverfsq-stream-options) object.
You should only attach one `AccessControl` object to each `MQlobberServer`
object. Attaching more than will result in unpredictable behaviour.
Only one `AccessControl` object can be attached to a `MQlobberServer` object at
a time. Trying to attach more than one will throw an exception.
**Parameters:**
- `{MQlobberServer} server` Object to which to apply access control. The object's [`subscribe_requested`](https://github.com/davedoesdev/mqlobber#mqlobberservereventssubscribe_requestedtopic-cb) and [`publish_requested`](https://github.com/davedoesdev/mqlobber#mqlobberservereventspublish_requestedtopic-stream-options-cb) events will be handled in order to allow or disallow client requests according to the topic specifiers passed to [`AccessControl`](#accesscontroloptions) or[`reset`](#accesscontrolprototyperesetoptions).
- `{MQlobberServer} server` Object to which to apply access control. The object's [`subscribe_requested`](https://github.com/davedoesdev/mqlobber#mqlobberservereventssubscribe_requestedtopic-cb) and [`publish_requested`](https://github.com/davedoesdev/mqlobber#mqlobberservereventspublish_requestedtopic-stream-options-cb) events will be handled in order to allow or disallow client requests according to the topic specifiers passed to [`AccessControl`](#accesscontroloptions) or[`reset`](#accesscontrolprototyperesetoptions). For blocking messages delivered to clients, a [`QlobberFSQ`](https://github.com/davedoesdev/qlobber-fsq#qlobberfsqoptions) `filter` function is installed on the server's file system queue.
<sub>Go: [TOC](#tableofcontents) | [AccessControl.prototype](#toc_accesscontrolprototype)</sub>
Expand Down
2 changes: 1 addition & 1 deletion coverage/coverage.json

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>84/84</span>
<span class='fraction'>82/82</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>35/35</span>
<span class='fraction'>32/32</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
Expand All @@ -37,7 +37,7 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>84/84</span>
<span class='fraction'>82/82</span>
</div>
</div>
</div>
Expand All @@ -62,13 +62,13 @@ <h1>
<td class="file high" data-value="mqlobber-access-control/"><a href="mqlobber-access-control/index.html">mqlobber-access-control/</a></td>
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
<td data-value="100" class="pct high">100%</td>
<td data-value="84" class="abs high">84/84</td>
<td data-value="82" class="abs high">82/82</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="35" class="abs high">35/35</td>
<td data-value="32" class="abs high">32/32</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="11" class="abs high">11/11</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="84" class="abs high">84/84</td>
<td data-value="82" class="abs high">82/82</td>
</tr>

</tbody>
Expand All @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 10 2016 08:07:21 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Sep 11 2016 22:00:25 GMT+0100 (BST)
</div>
</div>
<script src="prettify.js"></script>
Expand Down
14 changes: 7 additions & 7 deletions coverage/lcov-report/mqlobber-access-control/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>84/84</span>
<span class='fraction'>82/82</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>35/35</span>
<span class='fraction'>32/32</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
Expand All @@ -37,7 +37,7 @@ <h1>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>84/84</span>
<span class='fraction'>82/82</span>
</div>
</div>
</div>
Expand All @@ -62,13 +62,13 @@ <h1>
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
<td data-value="100" class="pct high">100%</td>
<td data-value="84" class="abs high">84/84</td>
<td data-value="82" class="abs high">82/82</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="35" class="abs high">35/35</td>
<td data-value="32" class="abs high">32/32</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="11" class="abs high">11/11</td>
<td data-value="100" class="pct high">100%</td>
<td data-value="84" class="abs high">84/84</td>
<td data-value="82" class="abs high">82/82</td>
</tr>

</tbody>
Expand All @@ -77,7 +77,7 @@ <h1>
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sat Sep 10 2016 08:07:21 GMT+0100 (BST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Sep 11 2016 22:00:25 GMT+0100 (BST)
</div>
</div>
<script src="../prettify.js"></script>
Expand Down
Loading

0 comments on commit c62ba21

Please sign in to comment.