aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-02-04 08:21:25 +0100
committerSpp <spp@jorge.gr>2013-02-04 09:04:33 +0100
commitb980aff83e214bab60f141c879c2a392789a4d16 (patch)
tree0f9695e62bf2027574655766970cbe6ee0a50f43 /src/server/scripts
parentdb9b0875500da077be1d0aa808999f59ed0663bc (diff)
Core: Implement Role based Access Control
- This system will give more control of actions an account can perform. System defines: - Permissions to perform some action - Roles: a set of permissions that have some relation - Groups: a set of roles that have some relation Operations: - Grant: Assign and allow - Deny: Assign and do not allow - Revoke: Remove Precedence to know if something can be done: Grant, Deny. That means, if you are granted some action by a role but you have denied the permission, the action can not be done. Some Rules: - Groups can only have roles - Roles can only have permissions - An account can be assigned granted and denied roles. Permissions inherited from roles are granted if roles is granted and denied if roles is denied - An account can be assigned granted and denied permissions - An account can have multiple groups, roles and permissions - An account can not have same role granted and denied at same time - An acconnt can not have same permission granted and denied at same time - Id 0 can not be used to define a group, role or permission Added some permissions as a sample of use (Instant Logout, Skip Queue, Join BGs, Join DF) and some permissions as a workaround to commands till command system is modified to use RBAC
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/CMakeLists.txt1
-rw-r--r--src/server/scripts/Commands/cs_account.cpp34
2 files changed, 4 insertions, 31 deletions
diff --git a/src/server/scripts/Commands/CMakeLists.txt b/src/server/scripts/Commands/CMakeLists.txt
index 7b9e2444952..83e97b2c80d 100644
--- a/src/server/scripts/Commands/CMakeLists.txt
+++ b/src/server/scripts/Commands/CMakeLists.txt
@@ -35,6 +35,7 @@ set(scripts_STAT_SRCS
Commands/cs_modify.cpp
Commands/cs_npc.cpp
Commands/cs_quest.cpp
+ Commands/cs_rbac.cpp
Commands/cs_reload.cpp
Commands/cs_reset.cpp
Commands/cs_tele.cpp
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp
index 3a20a03bb4a..4dc44bbfc58 100644
--- a/src/server/scripts/Commands/cs_account.cpp
+++ b/src/server/scripts/Commands/cs_account.cpp
@@ -106,7 +106,7 @@ public:
if (!accountName || !password)
return false;
- AccountOpResult result = AccountMgr::CreateAccount(std::string(accountName), std::string(password));
+ AccountOpResult result = sAccountMgr->CreateAccount(std::string(accountName), std::string(password));
switch (result)
{
case AOR_OK:
@@ -503,36 +503,8 @@ public:
return false;
}
- // If gmRealmID is -1, delete all values for the account id, else, insert values for the specific realmID
- PreparedStatement* stmt;
-
- if (gmRealmID == -1)
- {
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
-
- stmt->setUInt32(0, targetAccountId);
- }
- else
- {
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM);
-
- stmt->setUInt32(0, targetAccountId);
- stmt->setUInt32(1, realmID);
- }
-
- LoginDatabase.Execute(stmt);
-
- if (gm != 0)
- {
- stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS);
-
- stmt->setUInt32(0, targetAccountId);
- stmt->setUInt8(1, uint8(gm));
- stmt->setInt32(2, gmRealmID);
-
- LoginDatabase.Execute(stmt);
- }
-
+ RBACData* rbac = isAccountNameGiven ? NULL : handler->getSelectedPlayer()->GetSession()->GetRBACData();
+ sAccountMgr->UpdateAccountAccess(rbac, targetAccountId, uint8(gm), gmRealmID);
handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm);
return true;