---
title: "Chapter 16. Reactivity Under Access Control"
url: "https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16"
locale: "en"
author: "Mikhail Savchenko (Mike Fluff)"
updated: "2026-11-18T12:24:57.879Z"
book: "https://www.mikefluff.com/en/books/from-closures-to-autonomous-systems"
access: "lead-in"
purchase: "https://www.mikefluff.com/en/books/from-closures-to-autonomous-systems"
alternates:
  - locale: "ru"
    url: "https://www.mikefluff.com/ru/read/from-closures-to-autonomous-systems/ch16"
    markdown: "https://www.mikefluff.com/ru/read/from-closures-to-autonomous-systems/ch16.md"
  - locale: "en"
    url: "https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16"
    markdown: "https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16.md"
  - locale: "pt"
    url: "https://www.mikefluff.com/pt/read/from-closures-to-autonomous-systems/ch16"
    markdown: "https://www.mikefluff.com/pt/read/from-closures-to-autonomous-systems/ch16.md"
---

# Chapter 16. Reactivity Under Access Control

*[JavaScript: From Closures to Autonomous Systems](https://www.mikefluff.com/en/books/from-closures-to-autonomous-systems)*

For many years a new Meteor application was created with two packages that every tutorial told you to remove first. The `autopublish` package sent every client the whole database, and the `insecure` package let any client write anything into any collection. With them a prototype came together in an evening, because you did not have to think about either subscriptions or methods. Remove them, and the prototype stopped showing anything until the programmer wrote at least one publication. Today `autopublish` no longer goes into new projects by default. But in those years the platform, having taken on data delivery, left the programmer one main question, who has the right to see and change what, and itself answered it with «everyone, everything».

Once these packages were removed, read access control in Meteor came down to the publication function. We saw it in the fourteenth chapter:

```
Meteor.publish('orders', function () {
  if (Roles.userIsInRole(this.userId, 'manager')) {
    return Orders.find();
  }
  return Orders.find({ owner: this.userId });
});
```

Whatever this function returns is what ends up in the user’s Minimongo. Meteor offered no separate place describing who may do what. Roles were added with a third-party package, most often `alanning:roles`, which is where the `Roles.userIsInRole` call comes from. The idea of roles itself is old. In 1992 David Ferraiolo and Richard Kuhn of NIST described role-based access control: permissions are granted to roles, people are given roles, and to change the permissions of an employee moved to another department it is enough to change their role. In 2014 NIST published a guide to the next step, where the decision is made based on attributes of the user, the data and the environment. But these are all models, and in Meteor the access rule lived inside a function that returns a cursor, and was exactly as careful as the programmer who wrote it.

---

The rest of this chapter is free on the site once the reader confirms an email address: https://www.mikefluff.com/en/read/from-closures-to-autonomous-systems/ch16
