security_tech_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
security_tech_notes [2007/03/29 20:00]
Glarawyn Added info for cache_mgr paramaters.
security_tech_notes [2007/04/09 19:39]
Glarawyn
Line 1: Line 1:
-====== BeBot's Security Management System ====== 
- 
-=== Introduction === 
-BeBot's Security Management System aims to provide a common interface and structure for dealing with all things security. This document provides a technical specification and my notes for the developer(s) of BeBot's security system.  
- 
 === Access Levels === === 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 groups, even though the SuperAdmin, Admin, and Leader levels have the same names as BeBot's default security groups.  
- 
 BeBot has 8 Access Levels: BeBot has 8 Access Levels:
-  - Owner (Bot Owner) +  - OWNER (Bot Owner) 
-  - SuperAdmin +  - SUPERADMIN 
-  - Admin +  - ADMIN 
-  - Leader +  - LEADER 
-  - Member (A member of the bot. Guild members in guildbot mode.) +  - MEMBER (A member of the bot. Guild members in guildbot mode.) 
-  - Guest (Someone added to the guildbot'guestlist (Not used in raidbot mode by default)) +  - GUEST (Someone added to the guildbot'guest list (Not used in raidbot mode by default)) 
-  - Anonymous (Someone who is not a guest or member, but sends a tell to the bot.) +  - ANONYMOUS (Someone who is not a guest or member, but sends a tell to the bot.) 
-  - Banned (Someone who has been banned.)+  - BANNED (Someone who has been banned.)
  
-All access is defined by these eight levels+=== Access Levels and Group Conventions === 
 +  - Access Levels should always be referred to in UPPERCASE letters. 
 +  - Security Groups are always referred to in lowercase letters. 
 +  - No spaces or special characters are allowed in group names
  
 === Determining a user's access === === Determining a user's access ===
Line 26: Line 22:
   * Config file hard coding.    * Config file hard coding. 
  
-order to bring all this information into one system, the $this -> bot -> security -> get_access_level($player) function will return the **highest** access level granted to the player. To determine the players access level, the get_access_level function first checks the owner and superadmins configured in Bot.conf. If the player is configured as the bot's owner in the bot's configuration file, 256 is returned and no further checks are done. If the player is configured as a superadmin, 255 is returned and no further checks are done. This prevents the configured owner and superadmin from accidentally being banned from the bot. +In order to bring all this information into one system, the $this -> bot -> security -> get_access_level($player) function will return the **highest** access level granted to the player. To determine the players access level, the get_access_level function first checks the owner and superadmins configured in Bot.conf. If the player is configured as the bot's owner in the bot's configuration file, 256 is returned and no further checks are done. If the player is configured as a superadmin, 255 is returned and no further checks are done. This prevents the configured owner and superadmin from accidentally being banned from the bot. 
  
 The second check is the status of the user in the users table. If the player is banned, no further checks are done and -1 is returned. Otherwise, the player's user level is stored in memory for use in subsequent checks.  The second check is the status of the user in the users table. If the player is banned, no further checks are done and -1 is returned. Otherwise, the player's user level is stored in memory for use in subsequent checks. 
  
-The third check is the player's Org Rank (in Guildbot mode only.) The bot owner can assign access levels to Org Ranks. For example, the President of an organization can be assigned LeaderAdmin, or SuperAdmin privileges without adding them to the bot's configuration file or one of BeBot's groups. If the access level assigned to the player's org rank is higher than the level assigned to them in the users table, the org rank access level is stored in memory (replacing the user level) for use in subsequent checks. +The third check is the player's Org Rank (in Guildbot mode only.) The bot owner can assign access levels to Org Ranks. For example, the President of an organization can be assigned LEADERADMIN, or SUPERADMIN privileges without adding them to the bot's configuration file or one of BeBot's groups. If the access level assigned to the player's org rank is higher than the level assigned to them in the users table, the org rank access level is stored in memory (replacing the user level) for use in subsequent checks. 
  
-The final check is default and custom groups. The bot's owner can add users to the LeaderAdmin, and SuperAdmin groups as well as create custom groups and assign the custom groups one of the 8 access levels. The highest group access level is found then compared with the highest access level that was discovered in check 2 and 3. The highest value is then returned. +The final check is default and custom groups. The bot's owner can add users to the leaderadmin, and superadmin groups as well as create custom groups and assign the custom groups one of the 8 access levels. The highest group access level is found then compared with the highest access level that was discovered in check 2 and 3. The highest value is then returned. 
  
 If any value is outside the valid range (A value less than -1 or greater than 256) is discovered, the function will return -1 banned as something seems to have gone wrong. (Tampering in the database, or editing the code to change defined access levels.) If any value is outside the valid range (A value less than -1 or greater than 256) is discovered, the function will return -1 banned as something seems to have gone wrong. (Tampering in the database, or editing the code to change defined access levels.)
- 
-=== Using 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 are assigned access levels.  
- 
-For example, your module should only be used by bot leaders. You would use the following code: 
-<code php> 
-if ($this -> bot -> security -> check_access($playername, "leader")) 
-    return "You are a Leader or higher on <botname>!"; 
-else 
-    return "You are not a Leader or higher on <botname>"; 
-</code> 
- 
-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.  
  
 === Security Cache Array === === Security Cache Array ===
Line 61: Line 44:
 $this -> cache['orgranks'][$rank_name] = INT; // access level $this -> cache['orgranks'][$rank_name] = INT; // access level
 </code> </code>
- 
-=== Security Cache Management === 
-The cache_mgr($action, $cache, $info, $more) function is used to add and remove information from the security cache. The cache manager function should only be called by functions that are modifying security (adding users, groups, changing group membership, etc.) 
- 
-Description of function paramaters: 
-$action: add or rem 
-$cache: Which cache to modify (groups, guests, members, banned, groupmem, orgranks) 
-$info: The information to add (or remove) 
-$more: Extra informaion needed for some actions. (Optional Paramater) 
- 
-Examples: 
-  * Add and remove a guest: 
-<code php> 
-$this -> cache_mgr("add", "guests", "Glarawyn"); 
-$this -> cache_mgr("rem", "guests", "Glarawyn"); 
-</code> 
-  * Add and remove a member: 
-<code php> 
-$this -> cache_mgr("add", "members", "Glarawyn"); 
-$this -> cache_mgr("rem", "members", "Glarawyn"); 
-</code> 
-  * Add and remove a ban: 
-<code php> 
-$this -> cache_mgr("add", "banned", "Glarawyn"); 
-$this -> cache_mgr("rem", "banned", "Glarawyn"); 
-</code> 
-  * Add a group:  
-<code php> 
-$tmp = array("gid" => "10", "name" => "groupname", "description" = "Example Group", "access_level" => 2); 
-$this -> cache_mgr("add", "groups", $tmp); 
-</code> 
-  * Remove a group:  
-<code php> 
-$this -> cache_mgr("rem", "groups", $groupname); 
-</code> 
-  * Add and remove a group member: 
-<code php> 
-$this -> cache_mgr("add", "groupmem", $groupname, $membername); 
-$this -> cache_mgr("rem", "groupmem", $groupname, $membername); 
-</code> 
-  * Change an org rank's access level: 
-<code php> 
-$this -> cache_mgr("add", "orgrank", "President", "255"); 
-</code> 
- 
-=== Security Module Functions === 
-Add a group: 
-<code php> 
-add_group($groupname, $description); 
-</code> 
- 
-Delete a group:  
-<code php> 
-del_group($target); 
-</code> 
- 
-Add a user to a group: 
-<code php> 
-add_group_member($target, $group) 
-</code> 
- 
-Remove a user from a group: 
-<code php> 
-del_group_member($target, $group) 
-</code> 
- 
-Add a member or guest: 
-<code php> 
-add_user($admin, $target, $level="guest") 
-</code> 
- 
-Remove a member or guest: 
-<code php> 
-del_user($admin, $target) 
-</code> 
- 
-Set a ban: 
-<code php> 
-set_ban($admin, $target) 
-</code> 
- 
-Remove a ban: 
-<code php> 
-rem_ban($admin, $target) 
-</code> 
- 
-Get group id (returns -1 if group doesn't exisit) 
-<code php> 
-get_gid($groupname) 
-</code> 
- 
- 
  • security_tech_notes.txt
  • Last modified: 2020/09/12 01:30
  • (external edit)