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

Create UnityPerms Class #88

Open
hakasapl opened this issue Jun 27, 2023 · 0 comments
Open

Create UnityPerms Class #88

hakasapl opened this issue Jun 27, 2023 · 0 comments
Assignees
Labels
feature New feature or request
Milestone

Comments

@hakasapl
Copy link
Collaborator

The UnityPerms class will be defined in resources/lib/UnityPerms.php. It will be responsible for determining whether a user is authorized to perform an action on another.

The class should have a constructor that accepts the $USER and $SQL var.

You will then create a method for each permission, which returns true if the user $uid has permission to perform the action on $operated_on in the group$group. For example, the following is sequential for the unity.approve_user permission:

  • checkApproveUser($uid, $operated_on, $group)
    • Return false if $uid is not in $group
    • Get the assigned role that $uid has in $group
    • Return true if the assigned role has the permission unity.admin or unity.admin_no_grant
    • Return false if the assigned role doesn't have the unity.approve_user permission
    • Return false if $operated_on's assigned role's priority is higher than or equal to $uid's assigned role priority
    • Otherwise return true

You will then create similar methods for:

  • unity.approve_user - Allows user to approve a user within a group
  • unity.deny_user - Allows user to deny a user within a group
  • unity.grant_role - Allows user to grant any role with a lower priority than theirs
  • unity.revoke_role - Allows user to revoke any role with a lower priority than theirs

These permission exist but do not need methods like above since they are blanket permissions:

  • unity.admin_no_grant - Allows for every permission within a group, but you cannot make others admins
  • unity.admin - Allows for every permission within a group, including assigning this permission

This issue will involve creating helper methods in UnitySQL for the queries, as well as creating the UnityPerms class, which is new. It could be helpful to include helper private methods in UnityPerms for getting the assigned role of a user within a group, or any other repeated code that happens in the checkXYZ methods defined above. Also note that the assign role and revoke role check methods will require an additional parameter $role to check whether the role they are trying to assign is able to be assigned.

@hakasapl hakasapl added the feature New feature or request label Jun 27, 2023
@hakasapl hakasapl added this to the Version 1.2.0 milestone Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants