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

Link to this comparison view

security_tech_notes [2013/09/12 22:49]
security_tech_notes [2020/09/12 01:30] (current)
Line 1: Line 1:
 +=== Access Levels ===
 +BeBot has 8 Access Levels:
 +  - OWNER (Bot Owner)
 +  - ADMIN
 +  - LEADER
 +  - MEMBER (A member of the bot. Guild members in guildbot mode.)
 +  - GUEST (Someone added to the guildbot's 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.)
 +  - BANNED (Someone who has been banned.)
 +=== 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 ===
 +BeBot keeps security related information in multiple locations:
 +  * users.user_level
 +  * whois.org_rank_id (Guildbot Mode Only)
 +  * admin_groups and admin_members
 +  * Config file hard coding. 
 +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 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 LEADER, ADMIN, 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 leader, admin, 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.)
 +=== Security Cache Array ===
 +<code php>
 +$this -> cache['groups'][$group_name]['acl'] = INT; // access level
 +$this -> cache['groups'][$group_name]['gid'] = INT; // group id number
 +$this -> cache['groups'][$group_name]['gn'] = STRING; // group name
 +$this -> cache['groups'][$group_name][$member_nick] = STRING; // group member nickname
 +$this -> cache['members'][$nickname] = STRING; // group member nickname
 +$this -> cache['guests'][$nickname] = STRING; // group member nickname
 +$this -> cache['banned'][$nickname] = STRING; // group member nickname
 +$this -> cache['orgranks'][$rank_name] = INT; // access level