-
Notifications
You must be signed in to change notification settings - Fork 188
Beginnings of a permission layer #2530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Could you give an example of how this would look? Also one relevant case would be to allow for localized permissions to e.g. forbid editing in a region (#81) |
|
Example for you can chain the dots as long as we don't reach the limit with recursions (for checking and adding permissions) |
|
Yeah, that seems reasonable (though with how much this is like a file system, I'd prefer if it used slashes). And of course we should pick a reasonable hierarchy, there should be a subcategory for commands, and inside of commands there should be a subcategory of get commands. Also one problem I see in your code is that if you enable a parent node then all the subtree information is lost. So if I give you permissions to run all commands, then take this permission away at a later point, you cannot even run /help anymore. |
|
okay so to adresss a few of your things I think I need somekind of global saved permission tree. So I think I will change the system so that as an example commands register themself like
I think I will introduce an optional
This is already supported? There is just not a good way to enable that. But through the global saved permission tree you could do things like: Also in that regard what do you think about * ? should it mabe just be usable at the top so |
I don't see how a global permission tree makes this easier, if at all I think it adds more edge cases, since the tree can change between updates (or just during normal gameplay). |
A lot can probably be done without the global tree but this not for what I see. |
|
The tree could maybe be also only used to get a picture of the current tree. So "*" instead of giving .all could just loop over all subPermissions in the global tree and add them all to the user. |
Yeah, that's what I would propose, just add an enum to each node which has 3 states allowed, forbidden and neutral. Another approach would be to kill recursion (and I'd always be in favor of that), and have just a single per player white and a single per player black list with the full permission path, then to check permission you'd basically just do: var iterator = std.mem.findRightMostIteratorWhateverIDontKnow(permissionPath, '/');
while(iterator.next()) |endIndex| {
if(blacklist.has(permissionPath[0..endIndex])) return false;
if(whitelist.has(permissionPath[0..endIndex])) return true;
}
return false; |
Do I understand that right that your |
|
Yeah, exactly. |
|
Changed to the black/whitelist system. (much better) For the whitelist / blacklist system as long as one group has whitelist access you are good to go. And for commands in general: I don't want to spend as much time into things like seperate permissions for the seperate subcommands as I think this would be much easier with #1425 |
|
The other important thing would be sharing with the client. This is relevant for anything that has client-side prediction (e.g. gamemode permissions, protector block, #2414, ...) For that I'd suggest to precompute the full set of permission from the user+group permission and send that to the client on each change. I think that would be easier and more efficient. Also another important reminder: Add testing! The permission system should have unit tests for all of its functionality. |
|
added tests and updated the description of the PR to reflect the changes |
|
Oh what I also wanted to mention is that I am thinking of adding a kinda root permission. currently there is no way for someone to have access to literally everything (without specifing every top level permission like "command"). So maybe if someone has access to "root" or some other keyword they just skip every check. Or we start everything with "/" and then you can get access to that |
|
Starting everything with a slash seems to be a reasonable option. |
This is a first step in the direction of #1961
Usage:
Users / Groups can be either whitelisted or blacklisted from a permissionPath.
For example a user can be granted the permission: "command" but be blacklisted from "command/spawn"
This would mean the user can run any command except spawn.
Users can be added to groups.
User permissions precede the group permissions, so if a user is blacklisted from the spawn command and joines a group who is whitelisted for the spawn command, the user would still have no permission to use spawn.
Tasks: