ACL Options to Cloud Validator #6975
Closed
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.
Extending on the 'how to improve default security' discussion in the community forum, I thought it could be handy for the built-in cloud validator to have some ACL enforcement.
With this PR, you can add the following validation:
or
Options:
As a string:
request.user
: request.user can read + write. No public accesspublicRead
: public read + no public writepublicWrite
: no public read + public writeroleRead:roleID
: role read for roleID + no write for roleIDroleWrite:roleID
: no role read for roleID + write for roleIDroleReadWrite:roleID
:role read for roleID + write for roleIDAs an object:
override
: whether the ACL should override the request.object ACLpublic
: public ACL options. Eitherread
,write
, orreadWrite
request.user
: request.user ACL options. Eitherread
,write
, orreadWrite
role:***
: role ACL options. Eitherread
,write
, orreadWrite
userID
: userID ACL options. Eitherread
,write
, orreadWrite
Also, could it be worth allowing setting the validation object in schema, or another method (maybe the first parameter can be a validation object? If you want the validator on a class but don't care for the beforeSave logic, you'll just get:
This is another quick project for Hacktober by me, no stress if it's not appropriate for Parse!