improvement: another approach on attachments field level authorization#1667
Merged
adrianthedev merged 3 commits intoApr 15, 2023
Merged
Conversation
|
Code Climate has analyzed commit 8b1c848 and detected 0 issues on this pull request. View more on Code Climate. |
adrianthedev
deleted the
improvement/apply_another_approach_on_field_level_authorization
branch
April 15, 2023 19:21
Contributor
|
This PR has been merged into Please check the release guide for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Fixes #1662
UPDATE
We have discovered that assigning different weights to two methods that police the same thing can be a complex and challenging task. As a result, we have decided to make
upload_attachments?,download_attachments?, anddelete_attachments?obsolete.From now on, only field level authorization will be considered. If it is defined and returns true, the action will be granted; otherwise, it will not.
Previous approach
How it works:upload_attachments?,download_attachments?anddelete_attachments?are first level authorization for attachments.upload_file_name?,download_file_name?anddelete_file_name?are second level authorization for each field.Lets pick uploads example:Ifupload_attachments?is NOT defined onlyupload_file_name?will count for authorize an action on a field...If
upload_attachments?is defined,upload_file_name?will count only ifupload_attachments?return true.Why? This way you can do something like:All admins and managers can upload attachments but only admins can upload that important document...ORNobody can upload any attachments but admins can upload that important document...ORAnyone can upload attachments but nobody can upload that important document.NOTICE:The follow example don't make much sense to use it...If upload_attachments are false, field level authorization will not be checked for uploads.
If you want to turn all uploads off and allow only specific uploads do NOT define
uploads_attachments?~~
Checklist: