-
Notifications
You must be signed in to change notification settings - Fork 7
K. ACL Rules
Jonathan Casarrubias edited this page May 3, 2018
·
1 revision
In this section, you will learn how to create and configure an OnixJS ACL Rule.
An ACL Rule is a relationship between certain ACL Groups and Component Methods, when creating an ACL Rule you define which exposed component methods are accessible for specific acl groups.
import {IACLRule, AccessType, GroupList} from '@onixjs/core';
import {AdminGroup} from './admin.group';
export class Admins implements IACLRule {
// Define methods to be granted: "*" is a wildcard for any component method
methods: string[] = ['*'];
// Define Access Grant
access: AccessType = AccessType.ALLOW;
// Define groups with the defined grant
groups: GroupList = [AdminGroup];
}
The code above is pretty simple, is a relationship many <-> many, between methods and certain groups of entities usually being users but not limited to.
import {Component, RPC, Stream} from '@onixjs/core';
import {Admins} from './admins.rule';
@Component({
acl: [Admins],
})
class MyComponent {
@RPC()
testRPC() {
return 'ALO WORLD';
}
@Stream()
testSTREAM() {}
}
The example above explains how to install an ACL Rule within a component, of course, it is not required to be used once, it can be used on any component you require.