Skip to content

Ensure User ACL's are more flexible and secure #3588#4860

Merged
flovilmart merged 5 commits intomasterfrom
fix/user-ACL-3588
Jun 28, 2018
Merged

Ensure User ACL's are more flexible and secure #3588#4860
flovilmart merged 5 commits intomasterfrom
fix/user-ACL-3588

Conversation

@flovilmart
Copy link
Contributor

@flovilmart flovilmart commented Jun 28, 2018

Hi guys! This is a fix for a long standing issue #3588. This should ensure user ACL'S let admins roles / other users manage them, while ensuring there is no data issue lock out possibility from the user himself.

This also fixes an issue where the beforeDelete would be called when the object is not writable because we were using the masterKey. It introduces a new isWrite on the find operation inthe DB so we can force the ACL's to use the write column (a find for an intended write).

If you got test suggestions, let me know.

@flovilmart flovilmart requested review from acinader and dplewis June 28, 2018 15:51
spec/helper.js Outdated

const openConnections = {};

console.log('YOLO!!!');
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@codecov
Copy link

codecov bot commented Jun 28, 2018

Codecov Report

Merging #4860 into master will decrease coverage by <.01%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4860      +/-   ##
==========================================
- Coverage   92.81%   92.81%   -0.01%     
==========================================
  Files         119      119              
  Lines        8813     8825      +12     
==========================================
+ Hits         8180     8191      +11     
- Misses        633      634       +1
Impacted Files Coverage Δ
src/RestWrite.js 93.79% <ø> (ø) ⬆️
src/Routers/UsersRouter.js 93.61% <0%> (ø) ⬆️
src/Auth.js 100% <100%> (ø) ⬆️
src/RestQuery.js 96.28% <100%> (+0.31%) ⬆️
src/Controllers/DatabaseController.js 94.69% <100%> (+0.02%) ⬆️
src/rest.js 97.64% <91.66%> (-1.14%) ⬇️
src/Controllers/SchemaController.js 96.25% <0%> (-0.24%) ⬇️

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 9e5d26e...9ac902c. Read the comment docs.

- Improves find method so we can attempt to read for a write poking the right ACL instead of using masterKey
- This ensure we do not run beforeDelete/beforeFind/beforeSave in the wrong scenarios
Copy link
Contributor

@acinader acinader left a comment

Choose a reason for hiding this comment

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

some nits and a question.

src/Auth.js Outdated
// Whether this auth could possibly modify the given user id.
// It still could be forbidden via ACLs even if this returns true.
Auth.prototype.couldUpdateUserId = function(userId) {
Auth.prototype.couldUpdateUserId = function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

so this is confusing to me now. the name couldUpdateUserId with a userId argument the way it was made sense why this would exist, but I can no longer really understand. Is this just loggedInOrMaster?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right :)

src/RestQuery.js Outdated
if (!this.auth.user) {
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN,
'This session token is invalid.');
'invalid session token');
Copy link
Contributor

Choose a reason for hiding this comment

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

cap the i: Invalid

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in small letters at other places, I can update it all (everywhere)

src/rest.js Outdated
// If we're trying to update a user without / with bad session token
if (className === '_User'
&& error.code === Parse.Error.OBJECT_NOT_FOUND) {
throw new Parse.Error(Parse.Error.SESSION_MISSING, 'insuffisant auth.');
Copy link
Contributor

Choose a reason for hiding this comment

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

insufficient

:).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

src/rest.js Outdated
if (className === '_User'
&& error.code === Parse.Error.OBJECT_NOT_FOUND) {
throw new Parse.Error(Parse.Error.SESSION_MISSING, 'insuffisant auth.');
throw new Parse.Error(Parse.Error.SESSION_MISSING, 'insufficient auth.');
Copy link
Contributor

Choose a reason for hiding this comment

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

man, I feel bad saying this, but, can you please leading cap this....

note that the sdk is consistent
https://github.com/parse-community/Parse-SDK-JS/search?q=throw+new&unscoped_q=throw+new

but parse-server isn't, but should be
https://github.com/parse-community/parse-server/search?p=2&q=throw+new&unscoped_q=throw+new****

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to feel bad :)

@flovilmart flovilmart merged commit 3bcb5a0 into master Jun 28, 2018
@flovilmart flovilmart deleted the fix/user-ACL-3588 branch June 28, 2018 20:31
flovilmart added a commit that referenced this pull request Aug 12, 2018
* Fixes an issue that would let the beforeDelete be called when user has no access to the object

* Ensure we properly lock user

- Improves find method so we can attempt to read for a write poking the right ACL instead of using masterKey
- This ensure we do not run beforeDelete/beforeFind/beforeSave in the wrong scenarios

* nits

* Caps insufficient
flovilmart added a commit that referenced this pull request Aug 12, 2018
* Fixes an issue that would let the beforeDelete be called when user has no access to the object

* Ensure we properly lock user

- Improves find method so we can attempt to read for a write poking the right ACL instead of using masterKey
- This ensure we do not run beforeDelete/beforeFind/beforeSave in the wrong scenarios

* nits

* Caps insufficient
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
…arse-community#4860)

* Fixes an issue that would let the beforeDelete be called when user has no access to the object

* Ensure we properly lock user

- Improves find method so we can attempt to read for a write poking the right ACL instead of using masterKey
- This ensure we do not run beforeDelete/beforeFind/beforeSave in the wrong scenarios

* nits

* Caps insufficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants