toucan
Super simple access tokens for Javascript
Create access tokens with a set of permissions, then pass the token around and let consumers check the token for permissions when needed.
Getting Started
Install toucan
npm install toucan --save
A simple example
var Toucan = ; var token = ;token ; // Elsewhere in your applicationtoken; true token; false
Example with roles
var Toucan = ; var RoleToken = module{ var token = ; ifrole == 'admin' token; ifrole == 'admin' || role == 'user' token; token; ifrole == 'banned' token; return token;}
var token; ifuser token = ;else token = ; iftoken // ..... edit profile ...... iftoken message;
Allow by default
By default, everything is denied unless explicitly permitted. You can enable allow-by-default by permitting '*'.
var Toucan = ; var token = ;token // All permissions are allowedtoken; true // Except this one, because it was explicitly deniedtoken; false