Differences
This shows you the differences between two versions of the page.
security [2013/09/12 22:49] |
security [2020/09/12 01:30] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== BeBot' | ||
+ | === Introduction === | ||
+ | BeBot' | ||
+ | |||
+ | === Access Levels === | ||
+ | The core of BeBot security is the Access Level. An Access Level is a defined constant that cannot be changed. Access Levels are not security groups. The SUPERADMIN, ADMIN, and LEADER levels have the same names as BeBot' | ||
+ | |||
+ | BeBot has 8 Access Levels: | ||
+ | - OWNER (Bot Owner) | ||
+ | - SUPERADMIN | ||
+ | - ADMIN | ||
+ | - LEADER | ||
+ | - MEMBER (A member of the bot. Guild members in guildbot mode.) | ||
+ | - GUEST (Someone added to the guildbot' | ||
+ | - ANONYMOUS (Someone who is not a guest or member, but sends a tell to the bot.) | ||
+ | - BANNED (Someone who has been banned.) | ||
+ | |||
+ | All access is defined by these eight levels. Membership is additive, meaning if you are in a higher level you automatically are a member of lower levels too, with BANNED being the notable exception. So an ADMIN is a MEMBER, GUEST, LEADER and ANONYMOUS too. | ||
+ | |||
+ | === User Levels, Org Ranks, and Security Groups === | ||
+ | A user's Access Level is determined by their user level, security group membership, and their org rank. When BeBot is in guildbot mode, all members of the org are made members of the bot when the bot reads the org's roster. In addition to assigning this access level, the bot's superadmins are able to assign Access Levels to Org Ranks. For example, every General in your org can be given Leader access via the Security Access Level interface. | ||
+ | |||
+ | In addition to the security options provided by user levels and org ranks, the bot's superadmins are able to create custom security groups and add players to these groups. When a new security group is created, it is assigned the access level ANONYMOUS. Use the Security Access Level interface to raise and lower the access of a custom group. | ||
+ | |||
+ | |||
+ | === Basic use the Security System in your modules === | ||
+ | To make security easy for module developers, the check_access function provides all the security checks you will need. When assigning security to commands, you should **always** use one of the eight access levels, not security groups. This allows the bot user full flexibility with their configuration as org ranks and custom security groups must be assigned access levels. | ||
+ | |||
+ | For example, if your module' | ||
+ | <code php> | ||
+ | if ($this -> bot -> security -> check_access($playername, | ||
+ | return "You are a Leader or higher on < | ||
+ | else | ||
+ | return "You are not a Leader or higher on < | ||
+ | </ | ||
+ | |||
+ | check_access returns TRUE if the player meets or exceeds the level you are checking. A player with an access or leader, admin, superadmin, or owner all meet or exceed the leader requirement. | ||
+ | |||
+ | |||
+ | BeBot check' | ||
+ | |||
+ | <code php> | ||
+ | if ($this -> bot -> security -> is_banned($name)) | ||
+ | { | ||
+ | $this -> bot -> send_ban($name, | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | // your code here. | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | When you wish to send notification about a ban, you should **always** use BeBot' | ||
+ | |||
+ | |||
+ | === Advanced use the Security System in your modules === | ||
+ | |||
+ | The Security Module provides the following functions for modifying the roster and security groups. | ||
+ | |||
+ | * Add a group: | ||
+ | <code php> | ||
+ | add_group($groupname, | ||
+ | </ | ||
+ | * Delete a group: | ||
+ | <code php> | ||
+ | del_group($target); | ||
+ | </ | ||
+ | * Add a user to a group: | ||
+ | <code php> | ||
+ | add_group_member($target, | ||
+ | </ | ||
+ | * Remove a user from a group: | ||
+ | <code php> | ||
+ | del_group_member($target, | ||
+ | </ | ||
+ | * Add a member or guest: | ||
+ | <code php> | ||
+ | add_user($admin, | ||
+ | </ | ||
+ | * Remove a member or guest: | ||
+ | <code php> | ||
+ | del_user($admin, | ||
+ | </ | ||
+ | * Set a ban: | ||
+ | <code php> | ||
+ | set_ban($admin, | ||
+ | </ | ||
+ | * Remove a ban: | ||
+ | <code php> | ||
+ | rem_ban($admin, | ||
+ | </ | ||
+ | * Get group id (returns -1 if group doesn' | ||
+ | <code php> | ||
+ | get_gid($groupname) | ||
+ | </ | ||
+ | |||
+ | |||
+ | === Expert use the Security System in your modules === | ||
+ | The cache_mgr($action, | ||
+ | |||
+ | Description of function parameters: | ||
+ | $action: add or rem | ||
+ | $cache: Which cache to modify (groups, guests, members, banned, groupmem, orgranks) | ||
+ | $info: The information to add (or remove) | ||
+ | $more: Extra information needed for some actions. (Optional Parameter) | ||
+ | |||
+ | * Add and remove a guest: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a member: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a ban: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add a group: | ||
+ | <code php> | ||
+ | $tmp = array(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Remove a group: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Add and remove a group member: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | $this -> cache_mgr(" | ||
+ | </ | ||
+ | * Change an org rank's access level: | ||
+ | <code php> | ||
+ | $this -> cache_mgr(" | ||
+ | </ |