You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| Suitable for? | Small and medium projects | Medium and large projects |
35
+
36
+
### What's Scope?
37
+
38
+
Definition as a verb is:
39
+
40
+
- look at carefully; scan.
41
+
- assess or investigate something.
42
+
43
+
In this library, I have scoped `action` and `object` which means you can have more control over these attributes.
44
+
45
+
Assume you have a publisher website with four types of users with the following roles:
46
+
47
+
-`admin` super user can do anything
48
+
-`manager` can do anything on articles
49
+
-`guest` can read only published article
50
+
-`user` the writers with limitations on time and location of article creation.
51
+
52
+
In microservice design patterns and restful's based on my opinion one of the best practices has focused on resource management, a single endpoint with a concentration on objects is better than having multiple endpoints or having complex business logic.
53
+
54
+
Now, if you want to handle all these policies in one place (e.g. `GET endpoint` read permission) how you can do this?
55
+
we suppose you use the `scoped` policy or `ability` grant definition instead of having multiple endpoints or having complex business logic.
25
56
26
57
### installation
27
58
28
59
```sh
29
60
npm install --save abacl
30
61
```
31
62
32
-
### Usage
63
+
### Usage and Dangling
33
64
34
65
Define your user policies as a json array, so you can store it in your database:
35
66
@@ -122,7 +153,7 @@ const article = {
122
153
Create a new access control object, then get the permission grants:
123
154
124
155
```ts
125
-
importAccessControl, { normalize }from'abacl';
156
+
importAccessControlfrom'abacl';
126
157
127
158
// The `strict` `AccessControlOption` control the scoped functionality
128
159
// default strict value is true, you can change it on the `can` method
@@ -131,7 +162,7 @@ const ac = new AccessControl(policies, { strict: false });
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L16">classes/acl.class.ts:16</a></li></ul></aside></li></ul></section></section>
83
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L16">classes/acl.class.ts:16</a></li></ul></aside></li></ul></section></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L13">classes/acl.class.ts:13</a></li></ul></aside></section>
90
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L13">classes/acl.class.ts:13</a></li></ul></aside></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L14">classes/acl.class.ts:14</a></li></ul></aside></section></section>
95
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L14">classes/acl.class.ts:14</a></li></ul></aside></section></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L25">classes/acl.class.ts:25</a></li></ul></aside></li></ul></section></section>
115
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L25">classes/acl.class.ts:25</a></li></ul></aside></li></ul></section></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L58">classes/acl.class.ts:58</a></li></ul></aside></li></ul></section>
136
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L58">classes/acl.class.ts:58</a></li></ul></aside></li></ul></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L39">classes/acl.class.ts:39</a></li></ul></aside></li></ul></section>
149
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L39">classes/acl.class.ts:39</a></li></ul></aside></li></ul></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L35">classes/acl.class.ts:35</a></li></ul></aside></li></ul></section>
162
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L35">classes/acl.class.ts:35</a></li></ul></aside></li></ul></section>
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/361d74c/src/classes/acl.class.ts#L43">classes/acl.class.ts:43</a></li></ul></aside></li></ul></section></section></div>
177
+
<li>Defined in <ahref="https://github.com/vhidvz/abacl/blob/7d4c12e/src/classes/acl.class.ts#L43">classes/acl.class.ts:43</a></li></ul></aside></li></ul></section></section></div>
0 commit comments