Idea: custom required permissions
See original GitHub issueFrom reading through the source code for checkPermissions
, it looks like there are two significant steps:
- Map the current hook to permissions which essentially builds out the necessary permissions for the current action being taken, based on the
options.namespace
and hook’smethod
and (potentiallyid
. - Check those permissions against those in the entity.
What this doesn’t address, is a scenario where the permission is based on the incoming payload, or other request factors e.g. I may have have a user who can update another user to an admin
, but not necessarily to an owner
. In this scenario, the required permissions step won’t be able to distinguish between these two, as both would be update methods and map to the same required permissions array.
I think there would be a couple of different ways to address this:
- Allow a function on
options
to override the classify function, or append to it. Not sure if this is too heavy handed or - Allow a selector
option
which selects the required permission from somewhere on thehook.params
e.g.checkPermissions({ permissionsFrom: 'requiredPermissions' });
and a hook withhook.params === { requiredPermissions: [ 'promote_user' ] }
. That way you can just add a hook before thecheckPermissions
method which would attach custom permissions to the hook.
Would love to get some feedback on this idea / alternative solutions to the overall issue. Cheers!
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (11 by maintainers)
Top Results From Across the Web
Auto-add Required Custom Permissions when assigning ...
Currently, when an existing Custom Permission is given a new Required Custom Permission, the required permission is automatically assigned to any Profiles ...
Read more >Files/Folders Default Permissions dialog | IntelliJ IDEA ...
By default, IntelliJ IDEA calculates and re-calculates the value of the field as you select or clear the desired checkboxes. You can also ......
Read more >Idea: Tableau Server permission for creating custom views
Currently, it is possible to restrict specific users from sharing their custom views by using the "Share Customized" permission on Tableau Server.
Read more >HubSpot Community - Granular custom object permissions
Search HubSpot Ideas or Create Idea ... +1 different custom objects require different permissions for users. inigolekunberri.
Read more >Different inspection behavior between two IDEA projects
ACCESS_FINE_LOCATION and GET_ACCOUNTS are both classified as "dangerous" permissions. · In both projects, as expected, warnings appear in foo() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Could the syntax be the same as a normal JavaScript Array
every
andsome
?Actually it’s looking more like it could just be this:
and then we don’t even have
isPermitted
. Just any helper hooks for checking permissions/ownership.@daffl I think that is the opposite of your
when
hook you were hoping for. So we can have:when
(synonymous withiff
)unless
(synonymous withiff(isNot())
)iffElse