1.1.16 • Published 6 years ago

smallorange-acl v1.1.16

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

CircleCI

Small Orange ACL

Reactive ACL's based on RxJS

Usage

	const Acl = require('smallorange-acl');
	const = new Model();

	const mockedArgs = {
		id: 'someId',
		select: ['id', 'name', 'password'],
		limit: 100
	};

	const mockedAuth = {
		namespace: 'someNamespace',
		role: 'admin',
		id: 'someId'
	};

	const aclRules = {
		// context, method or operation
		fetch: {
			// roles
			public: {
				expression: (args, auth, context) => {
					// ensure auth.id
					if(!auth.id){
						return false;	
					}
					
					// can return an Observable, confirming user existence for example
					return context.model.get(auth.id)
							.map(response => !!response);
				}
			},
			admin: true // grant free access,
			unpredictable: false // block all access
		}
	};

	const acl = new Acl(aclRules, {
		model
	});
	
	acl.execute.fetch(mockedArgs, mockedAuth, {
				rejectSilently: boolean,
				onReject: function
			})
			.mergeMap(aclargs => model.fetch(aclargs))
			.subscribe(nextFn, errFn);
1.1.16

6 years ago

1.1.15

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago