-
Notifications
You must be signed in to change notification settings - Fork 422
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
Fix JSON Merge on removing permissions (fixes #1322) #1353
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,23 +39,6 @@ only the fields whose value was changed are returned. If set to | |
``diff``, only the fields whose value became different than | ||
the one provided are returned. | ||
|
||
Permissions | ||
----------- | ||
|
||
In the JSON request payloads, at least one of ``data`` and ``permissions`` must be provided. Permissions can thus be modified independently from data. | ||
|
||
The :ref:`current user id <api-current-userid>` **is always added** among the ``write`` principals. | ||
|
||
See :ref:`api-permissions-payload`. | ||
|
||
.. | ||
.. Kinto.core feature, not used in Kinto: | ||
.. | ||
.. Read-only fields | ||
.. ---------------- | ||
|
||
.. If a read-only field is modified, a |status-400| error is returned. | ||
|
||
JSON Patch Operations | ||
--------------------- | ||
|
||
|
@@ -82,8 +65,20 @@ For more information about each operation, please refer to | |
`JSON-Patch Specification <https://tools.ietf.org/html/rfc6902>`_. | ||
|
||
This is very useful when altering permissions since there is no need to get | ||
the current value before adding some principal to the list. Value is not used | ||
on permission operations and can be omitted. | ||
the current value before adding some principal to the list. | ||
|
||
Permissions | ||
----------- | ||
|
||
.. In the JSON request payloads, at least one of ``data`` and ``permissions`` | ||
.. must be provided. | ||
|
||
When permissions are modified, the same behaviour used for the body is expected. | ||
But notice thought that there are some permissions specific behaviours, such as: | ||
|
||
1. The :ref:`current user id <api-current-userid>` **is always added** among the | ||
``write`` principals. | ||
2. Value is not used on permission JSON Patch operations and can be omitted. | ||
|
||
.. code-block:: javascript | ||
|
||
|
@@ -92,3 +87,17 @@ on permission operations and can be omitted. | |
{ "op": "add", "path": "/permissions/read/system.Everyone" }, | ||
{ "op": "remove", "path": "/permissions/read/fxa:bob" } | ||
] | ||
|
||
3. On JSON Merge operations, ``null`` values can be used to remove all principals | ||
from a specific permission level. As a consequence, using ``null`` for permissions | ||
on other types of patch operations is considered a no-op. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, maybe I misunderstood, I didn't think that was a consequence. I would have written something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From my understanding what I've described is the implemented behavior. This is what I've tried to explain in the PR by saying "As a side effect this allows passing null to regular patch operations with no effect". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, then I misunderstood. I thought we had logic to only do the preprocess/postprocess null step if we were in a merge patch. In that case, why do we have this preprocess/postprocess step, versus just allowing permissions to be nullable? I'm guessing it's because we want to only allow nulls in certain kinds of operations, but it seems like we added it to the PermissionSchema, so it seems like it's global anyhow? |
||
|
||
For more information on permissions, see :ref:`api-permissions-payload`. | ||
|
||
.. | ||
.. Kinto.core feature, not used in Kinto: | ||
.. | ||
.. Read-only fields | ||
.. ---------------- | ||
|
||
.. If a read-only field is modified, a |status-400| error is returned. |
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
but
andthough
(N.B. typo) are redundant -- either one is fine. I'd probably writenote
instead ofnotice
.permissions-specific
.