accesscontrol
Advanced tools
Changelog
v2.2.0 (2017-11-25)
This release greatly improves stability!
#permission()
method was affected.$extend
was used properly in the initial grants model, passed to the constructor or #setGrants()
. Fixes issue #22.true
in a specific case.#lock()
to throw a meaningful error if not successful.#hasRole()
and #hasResource()
methods to also accept a string array (to check for multiple at once), in addition to string
(single).ac.grant()...
will not throw (omitted parameter allowed) but ac.grant(undefined)...
will throw. This mitigates the chance of passing an unset variable by mistake.yarn
. Enabled test coverage via jest
. Added coveralls
support.Changelog
v2.0.0 (2017-10-05)
#setGrants()
) or passing null
, undefined
. This will throw. You need to either, explicitly call #reset()
or set grants to an empty object ({}
) in order to reset/empty grants safely.#access()
to #query()
. This is an alias for #can()
method.AccessControl#lock()
method that freezes the underlying grants model and disables all functionality for modifying it. This is useful when you want to restrict any changes. Any attempts to modify (such as #setGrants()
, #grant()
, #deny()
, etc) will throw after grants are locked. There is no unlock()
method. It's like you lock the door and swallow the key. :yum:AccessControl#isLocked
boolean
property.AccessControl#getInheritedRolesOf()
convenience method.AccessControl
instance. In order to prevent silent, future errors and mistakes; AccessControl
now thoroughly inspects the grants object passed to constructor or #setGrants()
method; and throws immediately if it has an invalid structure or configuration.AccessControl
to throw if any reserved keywords are used (i.e. for role, resource names) such as "$"
, "$extend"
.Changelog
v1.5.1 (2017-05-24)
import { AccessControl } from 'accesscontrol'
in TypeScript projects.Changelog
v1.5.0 (2017-03-08)
IAccessInfo
instead of role(s)) passed to .grant()
or .deny()
methods.ac.grant(['admin', 'superadmin']).readAny(['account', 'video'], ['*'])
. The caveat is that the resources (most probably) have different attributes; so you can either permit all, or only common attributes (e.g. ['id', 'name']
).