Replies: 6 comments
-
Hey @chladog, For more info on the security concerns and why this was changed you can read thye CVE: GHSA-35jj-vqcf-f2jf TLDR; by querying data you can reveal private information so you're correct that we need a mechanism to override allow access or some other way you might do it specific to your project. |
Beta Was this translation helpful? Give feedback.
-
hey @DanRibbens, As said Local API parameter would be ideal IMHO and here are two ideas:
|
Beta Was this translation helpful? Give feedback.
-
Wouldn't this be best to be done in your own collection afterRead hook to remove the property from the returned data after running your access control logic? That way querying would still be possible on restricted fields the way you want it but the data wouldn't be able to be read directly. I think this satisfies your requirements, what do you think @chladog? |
Beta Was this translation helpful? Give feedback.
-
I'm unsure that the needed behavior is possible to implement without being "too hacky" if you know what I mean @DanRibbens. It's quite similiar to the alternative I mentioned - that is running a query with Simply said I need to filter object against fields that are strictly private from users POV, but then return the filtered-out object shaped based on their rights. |
Beta Was this translation helpful? Give feedback.
-
I think I see the value here. Just so I am clear - when you are suggesting this:
You're looking to use the Local API already, but just need more granularity. Right? If so, I think we could add this to our roadmap. Might need to do a bit more thinking through it, but I don't see why this would be impossible / or a bad idea. Let me know. I will convert this to a Feature Request discussion and add it to our Roadmap in the meantime. 👍 |
Beta Was this translation helpful? Give feedback.
-
@jmikrut I need to ignore access-restriction for Local API's
|
Beta Was this translation helpful? Give feedback.
-
Link to reproduction
https://github.com/chladog/payload/tree/where-access-limited-error
To Reproduce
Following code is working fine until version 1.6.32 including, version 1.7.0 and newer throws an error.
readonly
group), but the where statement of the query is needs to to run against these restricted fields (readonly__domain
,readonly__status
).The Local API should find the correct collection item - ignoring the access rules in where statement, but then it should strip the item of all properties that user doesn't have access to.
This behaves as described until version 1.6.32 - the collection item is found based on the where statement, and the object returned is correctly stripped of all fields that user doesn't have access to - in this case collection item without readonly group.
In versions 1.7.0. and newer this throws an error. I musn't set
overrideAccess
totrue
as that would return collecton item including fields that user shouldn't have access to (readonly
group).Proposed Solution
I believe access control shouldn't apply to where statements of the query.
If for some reason you believe it should apply to where statements, then there should be additional mechanism to turn off such behavior something like
overrideAccessForWhere
, that would allow for described behavior.My Setup
mycollection
endpoints configmycollection
limited fieldaccess function
Describe the Bug
Payload Version
1.7.0+
Beta Was this translation helpful? Give feedback.
All reactions