PDA

View Full Version : How to RBAC



Wise
11-03-13, 02:01 AM
ello guys! It comes to my attention that people are having difficulties trying to communicate with this RBAC system that shouldn't have been implemented because it generates more support! Anyway, let's begin, shall we?

Contents:




1. Understanding the commands and tables
-1.1. List of the Permissions / Other - SQL Structure of all the RBAC tables (DEFAULT)
-1.2. Knowing your configuration
2 Giving GM Permissions
2.1 Giving Full Administrator permissions
2.2 Explaining rbac_linked_permissions



BEFORE CONTINUING:

Make sure you HAVE all of the data you're suppose to have in each table besides rbac_account_permissions. If you're missing table data, make sure the queries actually went through and didn't error.




~ List of the Permissions / Other - SQL Structure of all the RBAC tables (DEFAULT) ~

TrinityCore's RBAC (wiki) documentation:
RBAC: Role based Access Control - TrinityCore - KPsN Collaboration Platform (http://collab.kpsn.org/display/tc/RBAC%3A+Role+based+Access+Control)


TrinityCore staff has been updating this shit system so bare with me if this is outdated. If this is outdated, post in this thread or make a new thread in the support regarding if it is outdated.



~ Understanding the commands and tables ~



This is rather simple, so let's start off with the tables before heading into the commands right away.

You should have the following tables:




rbac_account_permissions -- Holds data of accounts that have permissions
rbac_permissions -- Holds data of permission Id/Names
rbac_default_permissions -- Holds data of default permissions
rbac_linked_permissions -- Holds data of linked permissions for other permissions to access



Now, the main tables that you will be inserting data into are (by default if you don't have custom commands):

rbac_account_permissions

The rbac_permissions holds all the permissions for you to access in "rbac_account_permissions". However, if you're wanting to make a custom command or a default permission setup, you have to edit rbac_default_permissions with the default permissions and rbac_linked_permission with the new default secID you made and link permissions you want to it.

(NOTE): You can select a player ingame and type in these commands to view their groups/permissions/roles without specifying their account name.


.: KNOWING YOUR COMMANDS :.

The main commands you'll most likely use are:

rbac account
rbac account list
rbac account grant
rbac account deny
rbac account revoke
rbac list

To see the command arguments, see cs_rbac.cpp for the correct syntax.

(NOTE): You can select a player ingame and type in these commands to assign their groups/permissions/roles without specifying their account name.


~ Giving GM Permissions ~


NOTE: Make sure you add the account's security type in the account_access table.

Now, I tested with this and came up with the results. To give a GameMaster Player, Moderator and GM Permissions, you will need to set their groups, permission (Specific commands only) and role. Don't get me wrong, it works perfectly.

To do this, we'll use a basic SQL query.


.: By SQL Query :.



NOTE: Look in rbac_default_permissions for the default permissions.
ok in rbac_default_permissions for the default permissions.

To grant your GameMaster permissions do:

INSERT INTO `rbac_account_permissions` (`accountId`, `permissionId`, `granted`, `realmId`) VALUES
('2', '193', '1', '-1');YOU CAN REPLACE THE VALUES WITH YOUR OWN. THEY ARE SPECIFIC AND CAN EASILY BE CHANGED.



~ Giving Full Administrator Permissions (All commands) ~
NOTE: Make sure you add the account's security type in the account_access table.
NOTE: Look in rbac_default_permissions for the default permissions.

To do this, we'll use a basic SQL query.
.: By SQL Query :.

INSERT INTO `rbac_account_permissions` (`accountId`, `permissionId`, `granted`, `realmId`) VALUES
('2', '192', '1', '-1');YOU CAN REPLACE THE VALUES WITH YOUR OWN. THEY ARE SPECIFIC AND CAN EASILY BE CHANGED.


ALWAYS REMEMBER: -1 is ALL REALMS. You can set permissions to a specific realm, for example 1, 2, 3, etc.. (RealmID goes by the amount of realms you have.)


~ Explaining rbac_linked_permissions ~
If you have a new custom permissionID or you want to edit an existing permissions linked permissions -- then this is what this table is for.

FOR EXAMPLE:
If I wanted let's say permissionID 199 (Player Commands) to have the permission 672, I would do this:


INSERT INTO `rbac_linked_permissions` (`id`, `linkedId`) VALUES (199, 672);


When I query that above to my DB, I linked permissionID (Player Commands) with 672. That means permission 199 Player Commands will have the command: reload npc_trainer. This is only an example, you don't really want to give the player command permission that command. :P

So, it makes sense, right? You link each permission in `linkedId` you want a permission to have.



I hope you enjoyed this guide on how to fully comprehend the RBAC system.