-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Create object fails when CLP user pointer create set to true public create set to false #6359
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
Comments
I think it works like this by design as we can see in this test case but I'm not sure why. @dplewis @acinader any idea? @TravisHeaver in the meantime I suggest you to enable |
This is by design, If we allow If you want to enforce a rule that some field should contain only the person who creates it - this has nothing to do with permissions, and @davimacedo suggestion perfectly covers such a case. To sum up - if you disable |
'handle those later' iirc is about other permissions that pass this validation function (sanity check) and handled later by adding query constraints: {where :
{"$and" : [
// original query
{ objectId: '0bj3ct1d' },
// added with Pointer permissions
{ $or: [
// to cover columns of type Pointer<_User>
{
'columnName': { __type: 'Pointer', className: '_User', objectId: 'us3r1d' },
objectId: '0bj3ct1d'
},
// to cover columns of type Array
{
'columnName':
{
$all: [
{ __type: 'Pointer', className: '_User', objectId: 'us3r1d' }
]
},
objectId: '0bj3ct1d'
}
]
]
} |
ok, thank you for the feedback, I will implement as suggested! |
Issue Description
Create new object fails when CLP public read/write set to false but pointer to _User (column named user) read/write set to true.
I am able to create objects when public create is set to true, however this leads to a vulnerability that a user can create an object for any user, there is no validation who is creating
Steps to reproduce
schema for the class
{
"_id": {
"$oid": "5e2895a31c9d440000ff973d"
},
"objectId": "string",
"updatedAt": "date",
"createdAt": "date",
"_metadata": {
"fields_options": {
"client": {
"required": false
},
"sku": {
"required": false
},
"note": {
"required": false
},
"currency": {
"required": false
},
"value": {
"required": false
},
"user": {
"required": true
},
"photo": {
"required": false
}
},
"indexes": {
"id": {
"_id": {
"$numberInt": "1"
}
}
},
"class_permissions": {
"get": {},
"find": {},
"count": {},
"create": {},
"update": {},
"delete": {},
"addField": {},
"readUserFields": ["user"],
"writeUserFields": ["user"]
}
},
"client": "Client",
"sku": "string",
"note": "string",
"currency": "string",
"value": "number",
"user": "_User",
"photo": "file"
}
Expected Results
When passing a valid session and the pointer to user matches that session users I expect the creation of a new object
Actual Outcome
{code: 119, error: "Permission denied for action create on class Sale."}
Environment Setup
Server
Database
Logs/Trace
error: Parse error: Permission denied for action create on class Sale. {"code":119,"stack":"Error: Permission denied for action create on class Sale.
at Function.validatePermission parse-server/lib/Controllers/SchemaController.js:1291:13)\n at SchemaController.validatePermission
parse-server/lib/Controllers/SchemaController.js:1304:29)
at validateClassName.then.then.schemaController
Which brings us here:
// No matching CLP, let's check the Pointer permissions
// And handle those later
const permissionField =
['get', 'find', 'count'].indexOf(operation) > -1
? 'readUserFields'
: 'writeUserFields';
as the note suggests 'handle those later' doesn't seem to get handled
The text was updated successfully, but these errors were encountered: