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
|
| _Role: ["name", "ACL"] | ||
| } | ||
|
|
||
| let CLPValidKeys = ['find', 'get', 'create', 'update', 'delete']; |
There was a problem hiding this comment.
Didn't knew it existed :) what's the full list?
There was a problem hiding this comment.
btw addField is never checked anywhere.
There was a problem hiding this comment.
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.
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 => { |
|
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. |
| fields: mongoSchemaAPIResponseFields(schema), | ||
| }; | ||
| if (schema._metadata && schema._metadata.class_permissions) { | ||
| result.classLevelPermissions = schema._metadata.class_permissions; |
There was a problem hiding this comment.
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.
|
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.