Fast RBAC - v2.0.0 / index / RBAC
index.RBAC
RBAC classref
• new RBAC(options?
)
RBAC constructor
Name | Type | Description |
---|---|---|
options |
Options |
RBAC options |
▸ add(role
, resource
, operation
, when?
): void
Adds new role to rules.
version
1.1.X
Name | Type | Description |
---|---|---|
role |
string |
user role |
resource |
string |
resource to access |
operation |
string |
allowed operation |
when? |
WhenFn <any > |
function for additional checks |
void
▸ can(role
, resource
, operation?
): boolean
Checks if user can perform operation without checking when condition.
version
1.X.X
Name | Type | Description |
---|---|---|
role |
string |
user role |
resource |
string |
resource to access |
operation? |
string |
operation on resource |
boolean
true if role has access to resources
▸ can<TContext
>(role
, resource
, operation
, context
): Promise
<boolean
>
Checks if user can perform operation with checking when condition if it's provided.
version
1.X.X
Name | Type |
---|---|
TContext |
any |
Name | Type | Description |
---|---|---|
role |
string |
user role |
resource |
string |
resource to access |
operation |
string |
operation on resource |
context |
TContext |
context passed to when function, set it to null |
Promise
<boolean
>
true if role has access to resources.
▸ remove(role
, resource?
, operation?
): void
Remove rule(s).
version
1.1.X
Name | Type | Default value | Description |
---|---|---|---|
role |
string |
undefined |
user role |
resource |
string |
'*' |
resource to access |
operation |
string |
'*' |
operation |
void