Do not apply authorization scope when building new resources#8986
Do not apply authorization scope when building new resources#8986michaelbaldry-il wants to merge 1 commit intoactiveadmin:masterfrom
Conversation
|
Hello, as per the |
Hmmm, interesting. I didn't find that in my searches. Do you have any suggestions about what we could do here? I now see there are scenarios where this makes sense but also scenarios where it is a bad idea (e.g. #8969). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8986 +/- ##
=======================================
Coverage 99.08% 99.08%
=======================================
Files 139 139
Lines 4046 4046
=======================================
Hits 4009 4009
Misses 37 37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The fact that specs are not failing is odd, it means that the fix is not testing correctly what it was supposed to fix |
The only spec in the merged PR just checks that it applies it, which I removed. |
Sorry, it's a small PR, but didn't notice that when I've commented. I mean, it was checking something, but is not testing what that scope is needed for (creation of nested objects?) However, in the original issue #8969 I can see that it is advised to not apply authorization scope on Copilot suggests to exclude some keys from the params. Should we exclude the primary key? Is this related to the primary key? |
|
The cause of our specific issue was scoping to You set your scope to be The comment in the pundit adapter suggests it is not meant to be used for I don't think excluding keys is the answer - it would mean you'd need to know in advance of this unexpected behaviour and plan for it, and know to add new ones as things change, which is easy to miss. I don't know what the correct solution is now though! Personally, I think the PR that introduced this may have needed more consideration before merging, but now it is established functionality that some rely on, it would seem. |
This is a possible fix for #8969.
It stops using
apply_authorization_scopeinbuild_new_resourceto avoid copying scoped attributes to the new records that are created.All tests pass but I'm unsure if it's possible there is reliance on this quirk by any users.