-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Adds CLP API to Schema router #898
Conversation
Personally I'd rather have this be part of the existing route rather than a new route (ie just add more info to the existing response to |
fine by me, what parameter do you suggest |
I like long names e.g. |
OK good, so on the PUT for the schema, and on the GET, I add the permissions to the current result? |
GET sounds right, for PUT I think just replace the permission on the _SCHEMA object entirely with whatever the include in the PUT, and make no modifications if the key isn't included. POST should probably support CLPs too, which shouldn't be too hard. The dashboard won't need it but people using the schemas API for their own purposes would probably find it handy. |
alrighty! |
10b0ee3
to
609661e
Compare
@flovilmart updated the pull request. |
Current coverage is
|
@@ -76,6 +76,17 @@ var requiredColumns = { | |||
_Role: ["name", "ACL"] | |||
} | |||
|
|||
let CLPValidKeys = ['find', 'get', 'create', 'update', 'delete']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about addField
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't knew it existed :) what's the full list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw addField is never checked anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 6 are the full list, you can verify using dashboard.parse.com. We should probably start checking addField :p Schema.js should be able to handle it without too much trouble, since there is that 'freeze' parameter.
@flovilmart updated the pull request. |
1 similar comment
@flovilmart updated the pull request. |
return; | ||
} | ||
Object.keys(perms).forEach((key) => { | ||
if (CLPValidKeys.indexOf(key) == -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function doesn't go far enough - it should also validate the contents of the keys to make sure they contain only roles and users. Also my preference would be to have it return true/false rather than throw.
I think since this is such a security critical feature we should do much more thorough testing than usual - verify that users/roles don't gain permissions after a failed attempt to change permissions, verify that they don't gain one permission after a different permission was modified, etc. At the very least we need to do some tests for users as well as for roles, which I don't currently see. Other than that and the stricter validation in |
Agreed with all that! |
4a229ee
to
7607bbc
Compare
7607bbc
to
e75d233
Compare
@flovilmart updated the pull request. |
5f300ca
to
20aebe2
Compare
…velPermissions: null
20aebe2
to
d71a58c
Compare
@flovilmart updated the pull request. |
}) | ||
}); | ||
|
||
it('should not be able to add a field', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong name
I see lots of tests for public permissions and for permissions on roles, but still none for users. Also we should have some tests for setting a permission to false explicitly (that really should have been done in the original CLP tests but now is as good a time to add them as any) |
@flovilmart updated the pull request. |
@drew-gross I updated, the setting permission to false blacklist, I can revert that if we don't want it now. Added 2 test cases with multiple users, as well as role and public |
@flovilmart updated the pull request. |
className: schema._id, | ||
fields: mongoSchemaAPIResponseFields(schema), | ||
}; | ||
if (schema._metadata && schema._metadata.class_permissions) { | ||
result.classLevelPermissions = schema._metadata.class_permissions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last request: Can you have the response always include the classLevelPermissions key? Have it return something equivalent to how the server behaves if there is actually no _metadata or _metadata.class_permissions, which appears to be the same as public everything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem!
One more small request. Sorry for having to go back and forth so many times on this. |
Don't be sorry, that's part of the process. In that case should we store it as the default? |
We shouldn't be making any database writes as part of a GET query, but I would be cool with saving in POST/PUT if you want to do that. Thats definitely optional though. |
Feel free to merge assuming tests pass. |
@flovilmart updated the pull request. |
Adds CLP API to Schema router
No description provided.