|
Project SkyFire Core
SkyFire 5.4.8 server core API documentation
|
#include <RBAC.h>
Public Member Functions | |||||
| uint32 | GetId () const | ||||
| Gets the Id of the Object. | |||||
| std::string const & | GetName () const | ||||
| Gets the Name of the Object. | |||||
| RBACData (uint32 id, std::string const &name, int32 realmId, uint8 secLevel=255) | |||||
HasPermission | |||||
Checks if certain action is allowed Checks if certain action can be performed.
Example Usage: | |||||
| bool | HasPermission (uint32 permission) const | ||||
| RBACPermissionContainer const & | GetPermissions () const | ||||
| Returns all the granted permissions (after computation). | |||||
| RBACPermissionContainer const & | GetGrantedPermissions () const | ||||
| Returns all the granted permissions. | |||||
| RBACPermissionContainer const & | GetDeniedPermissions () const | ||||
| Returns all the denied permissions. | |||||
GrantRole | |||||
Grants a permission Grants a permission to the account. If realm is 0 or the permission can not be added No save to db action will be performed. Fails if permission Id does not exists or permission already granted or denied
Example Usage: // previously defined "RBACData* rbac" with proper initialization uint32 permissionId = 2; if (rbac->GrantRole(permissionId) == RBAC_IN_DENIED_LIST) SF_LOG_DEBUG("entities.player", "Failed to grant permission %u, already denied", permissionId); | |||||
| RBACCommandResult | GrantPermission (uint32 permissionId, int32 realmId=0) | ||||
DenyPermission | |||||
Denies a permission Denied a permission to the account. If realm is 0 or the permission can not be added No save to db action will be performed. Fails if permission Id does not exists or permission already granted or denied
Example Usage: // previously defined "RBACData* rbac" with proper initialization uint32 permissionId = 2; if (rbac->DenyRole(permissionId) == RBAC_ID_DOES_NOT_EXISTS) SF_LOG_DEBUG("entities.player", "Role Id %u does not exists", permissionId); | |||||
| RBACCommandResult | DenyPermission (uint32 permissionId, int32 realmId=0) | ||||
Private Member Functions | |
CalculateNewPermissions | |
Calculates new permissions Calculates new permissions after some change The calculation is done Granted - Denied:
| |
| void | CalculateNewPermissions () |
| int32 | GetRealmId () const |
| bool | HasGrantedPermission (uint32 permissionId) const |
| Checks if a permission is granted. | |
| bool | HasDeniedPermission (uint32 permissionId) const |
| Checks if a permission is denied. | |
| void | AddGrantedPermission (uint32 permissionId) |
| Adds a new granted permission. | |
| void | RemoveGrantedPermission (uint32 permissionId) |
| Removes a granted permission. | |
| void | AddDeniedPermission (uint32 permissionId) |
| Adds a new denied permission. | |
| void | RemoveDeniedPermission (uint32 permissionId) |
| Removes a denied permission. | |
| void | AddPermissions (RBACPermissionContainer const &permsFrom, RBACPermissionContainer &permsTo) |
| Adds a list of permissions to another list. | |
| void | RemovePermissions (RBACPermissionContainer const &permsFrom, RBACPermissionContainer &permsTo) |
| Removes a list of permissions to another list. | |
ExpandPermissions | |||
Adds the list of linked permissions to the original list Given a list of permissions, gets all the inherited permissions
| |||
| uint32 | _id | ||
| std::string | _name | ||
| int32 | _realmId | ||
| uint8 | _secLevel | ||
| RBACPermissionContainer | _grantedPerms | ||
| RBACPermissionContainer | _deniedPerms | ||
| RBACPermissionContainer | _globalPerms | ||
| void | ExpandPermissions (RBACPermissionContainer &permissions) | ||
RevokePermission | |||||
Removes a permission Removes a permission from the account. If realm is 0 or the permission can not be removed No save to db action will be performed. Any delete operation will always affect "all realms (-1)" in addition to the realm specified Fails if permission not present
Example Usage: // previously defined "RBACData* rbac" with proper initialization uint32 permissionId = 2; if (rbac->RevokeRole(permissionId) == RBAC_OK) SF_LOG_DEBUG("entities.player", "Permission %u succesfully removed", permissionId); | |||||
| RBACCommandResult | RevokePermission (uint32 permissionId, int32 realmId=0) | ||||
| void | LoadFromDB () | ||||
| Loads all permissions assigned to current account. | |||||
| void | SetSecurityLevel (uint8 id) | ||||
| Sets security level. | |||||
| uint8 | GetSecurityLevel () const | ||||
| Returns the security level assigned. | |||||
| void | SavePermission (uint32 role, bool granted, int32 realm) const | ||||
| Saves a permission to DB, Granted or Denied. | |||||
| void | ClearData () | ||||
| Clears roles, groups and permissions - Used for reload. | |||||
|
inline |
Definition at line 765 of file RBAC.h.
References _deniedPerms, _globalPerms, _grantedPerms, _id, _name, _realmId, and _secLevel.
|
inlineprivate |
Adds a new denied permission.
Definition at line 928 of file RBAC.h.
References _deniedPerms.
Referenced by DenyPermission().
|
inlineprivate |
Adds a new granted permission.
Definition at line 916 of file RBAC.h.
References _grantedPerms.
Referenced by GrantPermission().
|
private |
|
private |
Definition at line 202 of file RBAC.cpp.
References _globalPerms, ExpandPermissions(), GetDeniedPermissions(), GetGrantedPermissions(), GetId(), GetName(), RemovePermissions(), and SF_LOG_TRACE.
Referenced by DenyPermission(), GrantPermission(), LoadFromDB(), and RevokePermission().
|
private |
Clears roles, groups and permissions - Used for reload.
Definition at line 254 of file RBAC.cpp.
References _deniedPerms, _globalPerms, and _grantedPerms.
Referenced by LoadFromDB().
| RBACCommandResult rbac::RBACData::DenyPermission | ( | uint32 | permissionId, |
| int32 | realmId = 0 ) |
Definition at line 83 of file RBAC.cpp.
References AddDeniedPermission(), CalculateNewPermissions(), GetId(), GetName(), HasDeniedPermission(), HasGrantedPermission(), rbac::RBAC_CANT_ADD_ALREADY_ADDED, rbac::RBAC_ID_DOES_NOT_EXISTS, rbac::RBAC_IN_GRANTED_LIST, rbac::RBAC_OK, sAccountMgr, SavePermission(), and SF_LOG_TRACE.
Referenced by rbac_commandscript::HandleRBACPermDenyCommand(), and LoadFromDB().
|
private |
Definition at line 226 of file RBAC.cpp.
References rbac::GetDebugPermissionString(), rbac::RBACPermission::GetLinkedPermissions(), sAccountMgr, and SF_LOG_DEBUG.
Referenced by CalculateNewPermissions().
|
inline |
Returns all the denied permissions.
Definition at line 797 of file RBAC.h.
References _deniedPerms.
Referenced by CalculateNewPermissions(), and rbac_commandscript::HandleRBACPermListCommand().
|
inline |
Returns all the granted permissions.
Definition at line 795 of file RBAC.h.
References _grantedPerms.
Referenced by CalculateNewPermissions(), and rbac_commandscript::HandleRBACPermListCommand().
|
inline |
Gets the Id of the Object.
Definition at line 771 of file RBAC.h.
References _id.
Referenced by CalculateNewPermissions(), DenyPermission(), GrantPermission(), rbac_commandscript::HandleRBACPermDenyCommand(), rbac_commandscript::HandleRBACPermGrantCommand(), rbac_commandscript::HandleRBACPermListCommand(), rbac_commandscript::HandleRBACPermRevokeCommand(), LoadFromDB(), rbac_commandscript::ReadParams(), RevokePermission(), and SavePermission().
|
inline |
Gets the Name of the Object.
Definition at line 769 of file RBAC.h.
References _name.
Referenced by CalculateNewPermissions(), DenyPermission(), GrantPermission(), rbac_commandscript::HandleRBACPermDenyCommand(), rbac_commandscript::HandleRBACPermGrantCommand(), rbac_commandscript::HandleRBACPermListCommand(), rbac_commandscript::HandleRBACPermRevokeCommand(), LoadFromDB(), and RevokePermission().
|
inline |
Returns all the granted permissions (after computation).
Definition at line 793 of file RBAC.h.
References _globalPerms.
|
inlineprivate |
|
inline |
Returns the security level assigned.
Definition at line 880 of file RBAC.h.
References _secLevel.
Referenced by rbac_commandscript::HandleRBACPermListCommand().
| RBACCommandResult rbac::RBACData::GrantPermission | ( | uint32 | permissionId, |
| int32 | realmId = 0 ) |
Definition at line 39 of file RBAC.cpp.
References AddGrantedPermission(), CalculateNewPermissions(), GetId(), GetName(), HasDeniedPermission(), HasGrantedPermission(), rbac::RBAC_CANT_ADD_ALREADY_ADDED, rbac::RBAC_ID_DOES_NOT_EXISTS, rbac::RBAC_IN_DENIED_LIST, rbac::RBAC_OK, sAccountMgr, SavePermission(), and SF_LOG_TRACE.
Referenced by rbac_commandscript::HandleRBACPermGrantCommand(), and LoadFromDB().
|
inlineprivate |
Checks if a permission is denied.
Definition at line 910 of file RBAC.h.
References _deniedPerms.
Referenced by DenyPermission(), GrantPermission(), and RevokePermission().
|
inlineprivate |
Checks if a permission is granted.
Definition at line 904 of file RBAC.h.
References _grantedPerms.
Referenced by DenyPermission(), GrantPermission(), and RevokePermission().
| bool rbac::RBACData::HasPermission | ( | uint32 | permission | ) | const |
Definition at line 31 of file RBAC.cpp.
References _globalPerms, CONFIG_RBAC_FREE_PERMISSION_MODE, and sWorld.
| void rbac::RBACData::LoadFromDB | ( | ) |
Loads all permissions assigned to current account.
Definition at line 170 of file RBAC.cpp.
References _secLevel, CalculateNewPermissions(), ClearData(), DenyPermission(), GetId(), GetName(), GetRealmId(), GrantPermission(), LOGIN_SEL_RBAC_ACCOUNT_PERMISSIONS, LoginDatabase, sAccountMgr, PreparedStatement::setInt32(), PreparedStatement::setUInt32(), and SF_LOG_DEBUG.
Referenced by rbac_commandscript::ReadParams(), and SetSecurityLevel().
|
inlineprivate |
Removes a denied permission.
Definition at line 934 of file RBAC.h.
References _deniedPerms.
Referenced by RevokePermission().
|
inlineprivate |
Removes a granted permission.
Definition at line 922 of file RBAC.h.
References _grantedPerms.
Referenced by RevokePermission().
|
private |
Removes a list of permissions to another list.
Definition at line 220 of file RBAC.cpp.
Referenced by CalculateNewPermissions().
| RBACCommandResult rbac::RBACData::RevokePermission | ( | uint32 | permissionId, |
| int32 | realmId = 0 ) |
Definition at line 137 of file RBAC.cpp.
References CalculateNewPermissions(), GetId(), GetName(), HasDeniedPermission(), HasGrantedPermission(), LOGIN_DEL_RBAC_ACCOUNT_PERMISSION, LoginDatabase, rbac::RBAC_CANT_REVOKE_NOT_IN_LIST, rbac::RBAC_OK, RemoveDeniedPermission(), RemoveGrantedPermission(), PreparedStatement::setInt32(), PreparedStatement::setUInt32(), and SF_LOG_TRACE.
Referenced by rbac_commandscript::HandleRBACPermRevokeCommand().
Saves a permission to DB, Granted or Denied.
Definition at line 127 of file RBAC.cpp.
References GetId(), LOGIN_INS_RBAC_ACCOUNT_PERMISSION, LoginDatabase, PreparedStatement::setBool(), PreparedStatement::setInt32(), and PreparedStatement::setUInt32().
Referenced by DenyPermission(), and GrantPermission().
|
inline |
|
private |
Granted permissions
Definition at line 962 of file RBAC.h.
Referenced by AddDeniedPermission(), ClearData(), GetDeniedPermissions(), HasDeniedPermission(), RBACData(), and RemoveDeniedPermission().
|
private |
Denied permissions
Definition at line 963 of file RBAC.h.
Referenced by CalculateNewPermissions(), ClearData(), GetPermissions(), HasPermission(), and RBACData().
|
private |
Account SecurityLevel
Definition at line 961 of file RBAC.h.
Referenced by AddGrantedPermission(), ClearData(), GetGrantedPermissions(), HasGrantedPermission(), RBACData(), and RemoveGrantedPermission().
|
private |
Definition at line 957 of file RBAC.h.
Referenced by GetId(), and RBACData().
|
private |
|
private |
|
private |
RealmId Affected
Definition at line 960 of file RBAC.h.
Referenced by GetSecurityLevel(), LoadFromDB(), RBACData(), and SetSecurityLevel().