1.0.0 • Published 7 years ago

iam-tools v1.0.0

Weekly downloads
17
License
MIT
Repository
github
Last release
7 years ago

iam-tools

Faciliates work with permissions of type:

[ {
	type: "type",
	identifier: "identifier" | "*",
	permissions: [
		"scope1:scope2"
		"scope1:scope3"
		"scope4:scope5:scope6"
		"scope7"
	]
} ]

Checking permissions

let userPermissions = [ {
	type: "television",
	identifier: "*",
	permissions: [
		"turn",
	]
}, {
	type: "television",
	identifier: "Acme 1000",
	permissions: [
		"watch:sports",
		"watch:news"
	]	
} ];

let john = new IAMUser(userPermissions);

assert.equal(john.hasPermission("Acme 1000", "television:turn:on"), true);
assert.equal(john.hasPermission("Acme 1000", "television:watch:news"), true);
assert.equal(john.hasPermission("Acme 2000", "television:turn"), true);
assert.equal(john.hasPermission("*", "television:turn"), true);

assert.equal(john.hasPermission("Acme 1000", "television:watch:vod"), false);
assert.equal(john.hasPermission("Acme 1000", "device:dismantle"), false);