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

New: requireAnyUserRoles and requireAllUserRoles for Parse Cloud Validator #7097

Merged
merged 12 commits into from
Feb 12, 2021

Conversation

dblythy
Copy link
Member

@dblythy dblythy commented Dec 26, 2020

New Pull Request Checklist

Issue Description

  • Adds requireAnyUserRoles to the inbuilt Parse Cloud validator options. If specified, req.user must have any roles with specified name.
  • Adds requireAllUserRoles to the inbuilt Parse Cloud validator options. If specified, req.user must have all roles with specified name.

You can also set these parameters to a function (async too) that returns an array of role names.

Related issue: #7093

TODOs before merging

  • Add test cases
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)

@codecov
Copy link

codecov bot commented Dec 26, 2020

Codecov Report

Merging #7097 (2fb7827) into master (27d56f0) will increase coverage by 0.06%.
The diff coverage is 94.69%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7097      +/-   ##
==========================================
+ Coverage   93.98%   94.04%   +0.06%     
==========================================
  Files         172      172              
  Lines       12834    12849      +15     
==========================================
+ Hits        12062    12084      +22     
+ Misses        772      765       -7     
Impacted Files Coverage Δ
src/cloud-code/Parse.Cloud.js 98.73% <ø> (ø)
src/triggers.js 94.86% <93.93%> (+0.27%) ⬆️
src/LiveQuery/ParseLiveQueryServer.js 95.33% <94.93%> (+0.40%) ⬆️
src/Routers/FunctionsRouter.js 94.11% <100.00%> (ø)
src/Controllers/LiveQueryController.js 96.42% <0.00%> (-0.13%) ⬇️
src/Routers/FilesRouter.js 88.28% <0.00%> (ø)
src/Controllers/UserController.js 97.63% <0.00%> (ø)
src/RestQuery.js 95.53% <0.00%> (+<0.01%) ⬆️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 95.85% <0.00%> (+0.07%) ⬆️
src/Controllers/SchemaController.js 97.32% <0.00%> (+0.19%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 27d56f0...2fb7827. Read the comment docs.

Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DX

spec/CloudCode.Validator.spec.js Outdated Show resolved Hide resolved
spec/CloudCode.Validator.spec.js Outdated Show resolved Hide resolved
@dblythy dblythy requested a review from Moumouls January 4, 2021 14:07
Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the standard getUser roles

src/triggers.js Outdated Show resolved Hide resolved
@dblythy
Copy link
Member Author

dblythy commented Jan 4, 2021

after adding auth to the other validation objects, I realised the LiveQuery cloud triggers don't pass in auth, and they assign user via userForSessionToken (not auth.authForSessionToken). I think this is a better way to do it for session cache etc.

src/triggers.js Outdated Show resolved Hide resolved
Copy link
Member

@Moumouls Moumouls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! thanks for your contribution @dblythy !
@mtrezza @davimacedo ?

Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job @dblythy ! Please find some comments below.

src/LiveQuery/ParseLiveQueryServer.js Show resolved Hide resolved
src/LiveQuery/ParseLiveQueryServer.js Show resolved Hide resolved
src/triggers.js Show resolved Hide resolved
@dblythy dblythy changed the title New: requireUserRole for Parse Cloud Validator New: requireAnyUserRoles and requireAllUserRoles for Parse Cloud Validator Feb 12, 2021
Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@davimacedo davimacedo merged commit 3d76643 into parse-community:master Feb 12, 2021
dplewis pushed a commit that referenced this pull request Feb 21, 2021
…dator (#7097)

* new: requireUserRole for Parse Cloud Validator

* change to requireUserRoles

* Update CHANGELOG.md

* revoke triggers

* Update triggers.js

* Update ParseLiveQueryServer.js

* Update ParseLiveQueryServer.js

* create requireUserRoles

* rename to requireAny and requireAll

* allow for a function
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@mtrezza mtrezza mentioned this pull request Mar 12, 2022
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants