Skip to content
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

Allow defining required privileges to bypass protection checks #11

Closed
2 of 3 tasks
S-S-X opened this issue May 21, 2020 · 1 comment
Closed
2 of 3 tasks

Allow defining required privileges to bypass protection checks #11

S-S-X opened this issue May 21, 2020 · 1 comment
Assignees
Labels
API Metatool API issues enhancement New feature or request Testing required Needs some testing before merging to main branch

Comments

@S-S-X
Copy link
Owner

S-S-X commented May 21, 2020

Allow defining required privileges to bypass protection checks for some nodes, this would allow defining administrative functions for registered tools.

Possible functionality:

  • Option to require verification each time protection bypass is used
  • Separate protection bypass settings for reading and writing
  • Allow overriding default protection checks with before_read / before_write callbacks
@S-S-X S-S-X added enhancement New feature or request API Metatool API issues labels May 21, 2020
@S-S-X S-S-X self-assigned this May 21, 2020
@S-S-X
Copy link
Owner Author

S-S-X commented May 22, 2020

Currently metatool:get_node does protection checks here https://github.com/S-S-X/metatool/blob/master/metatool/api.lua#L226-L230
Problem is that it does not know anything about operation and cannot therefore do selective allow or deny.

Currently flow goes like this:
item used -> minetest default on_use callback
-> metatool:on_use(itemname_clean, unpack({...})) api.lua#L46
-> metatool:get_node(tooldef, player, pointed_thing) api.lua#L91

Adding custom tool.is_protected(pos, player, node) callback for tool would be easy because all information for that is already available, that however wont make difference between read and write operations.

Better approach could be to provide node.can_read(pos, player, node) or tool.can_read(pos, player, node) and similar can_write methods.
This requires moving player:get_player_control() handling to be done before calling metatool:get_node method and metatool:get_node could then get information about operation that would be applied if node and position is returned.

@S-S-X S-S-X added the Testing required Needs some testing before merging to main branch label May 22, 2020
S-S-X added a commit that referenced this issue May 25, 2020
* Allow per node protection bypass / protection override #11 #9

* Bypass protection check completely if bypass privs present

* Simplify overcomplicated privilege check

Co-authored-by: SX <sx@minetest>
@S-S-X S-S-X closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Metatool API issues enhancement New feature or request Testing required Needs some testing before merging to main branch
Projects
None yet
Development

No branches or pull requests

1 participant