A redis based data structure that maps users and collaborators onto project names
A redis data structure for users collaborating on projects.
$ npm install collaborator-map
You need a Redis server running, you can provide the connection details to the constructor.
First - create a new map connected to the redis server:
var Collaborators = require'collaborator-map';var map = Collaboratorshost:'127.0.0.1'port:6379// this will be prepended to all redis keys used by the mapprefix:'mycustomprefix'
When a user creates a new resource that requires access control - tell the map about the:
// project_id = binocarlos/countries// user_id = binocarlos// access = privatemapcreate_project'binocarlos/countries' 'binocarlos' 'private'
There are 3 access levels a given user can obtain with a resource:
To get the access level for any user on a particular project id:
mapget_access'binocarlos/countries' 'otheruser'// from our example above access would be 'none' - the project is private
The people who can write to a project (or read a private one) are called 'collaborators'.
By default the owner of a project is a collaborator (and cannot be removed as one).
You can added and remove collaborators to a project:
Add a user:
mapadd_collaborator'bobsnewprojects' 'pete' next;
Remove a user:
mapremove_collaborator'bobsnewprojects' 'pete' next;
If for some reason you want to change the id by which you refer to a project:
maprename_project'oldprojectid' 'newprojectid' next;
You can list the projects that a user can access.
The list contains objects with the following properties:
mapget_projects'bob'// projects is an array of objects