0.4.0-pre.af06b9c7 • Published 8 years ago

@yaacl/memory-adapter v0.4.0-pre.af06b9c7

Weekly downloads
-
License
ISC
Repository
github
Last release
8 years ago

YAACL - Memmory Adapter

The memory adapter can mainly used for prototyping or tests, since it does not persist any ACL information.

How to use

  1. Install the yaacl core and an adapter of your choice:
yarn install @yaacl/core @yaacl/memory-adapter
  1. Create a yaacl and use it:
import { Yaacl, Privileges, SecurityIdentity, ObjectIdentity } from '@yaacl/core';
import { MemoryAdapter } from '@yaacl/memory-adapter';

const yaacl = new Yaacl(new MemoryAdapter());

// a security identity could be a user, a role...
const securityIdentity: SecurityIdentity = {
	getSecurityId: () => 'user-242',
};

// an object identity could be anything, like a blog post, a page...
const objectIdentity: ObjectIdentity = {
	getObjectId: () => 'object-4664';
};

const example = async () => {
  await yaacl.grant(securityIdentity, objectIdentity, Privileges.READ);
  await yaacl.granted(securityIdentity, objectIdentity, Privileges.READ); // true
  await yaacl.granted(securityIdentity, objectIdentity, Privileges.WRITE) // false
}

example();

For a full documentation of YAACL, please visit our Wiki

1.0.1

7 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago