jpie 4.1.11.pre.202611230311 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +4 -2
- data/lib/json_api/controllers/concerns/relationships/removal.rb +1 -0
- data/lib/json_api/controllers/relationships_controller.rb +2 -2
- data/lib/json_api/serialization/concerns/deserialization_helpers.rb +6 -2
- data/lib/json_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2c905bb8a16dd6c75c41cb25219cff95625bbce95df01c061a26ab22e82fda5
|
|
4
|
+
data.tar.gz: 4f78eaa61f0690aae23a7a45d2038f7c4d039112c30d671111f251fb07e66736
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d4684d2714737a79ba4204638172cfc09cc2b2809562dde0966a3f4c6627c593350dfeb4fd123a79caf3abe8d8e450e3c5b1e2ff258a7458cca576a0e6576ca
|
|
7
|
+
data.tar.gz: 9e6552a9d3acc2c4c8ece83d01587fb93712bb980683b12cd061fbf5e8ff4510c84f11d8cb3512f49e66a9aa00964f1d1d312eb6b42eb38c8df42d478b6fc619
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,23 @@ at release time.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.2.0] - 2026-11-24
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **Gate an attachment by the declared write lists, as a relationship is gated.**
|
|
15
|
+
A resource that declares `creatable_fields` or `updatable_fields` now refuses a
|
|
16
|
+
write to an ActiveStorage attachment that the list does not name. The refusal
|
|
17
|
+
is 403 Forbidden, the same as for an unnamed relationship. It covers:
|
|
18
|
+
- an attachment named under `relationships` in a POST or PATCH body;
|
|
19
|
+
- `DELETE /<type>/<id>/relationships/<attachment>`, which purged the file with
|
|
20
|
+
no check.
|
|
21
|
+
|
|
22
|
+
A resource that declares no list for the action keeps the older behavior.
|
|
23
|
+
**Upgrade:** add each attachment that clients write to the resource's field
|
|
24
|
+
lists. This changes behavior, so release it as a minor version.
|
|
25
|
+
Regression spec: `attachment_allowlist_spec.rb`.
|
|
26
|
+
|
|
10
27
|
## [4.1.10] - 2026-11-20
|
|
11
28
|
|
|
12
29
|
### Fixed
|
data/README.md
CHANGED
|
@@ -176,8 +176,10 @@ adjusts the inherited list — `super - [:role]` — returns a plain array, the
|
|
|
176
176
|
as one that states a fresh list, so jpie cannot tell the two apart. Call the DSL
|
|
177
177
|
to close the list.
|
|
178
178
|
|
|
179
|
-
The gate
|
|
180
|
-
|
|
179
|
+
The gate covers an ActiveStorage attachment the same way. Name the attachment in
|
|
180
|
+
a declared list to let a client attach a file in a POST or PATCH body, or remove
|
|
181
|
+
one through `DELETE /<type>/<id>/relationships/<attachment>`. A client that
|
|
182
|
+
writes an attachment the action's list omits meets 403 Forbidden.
|
|
181
183
|
|
|
182
184
|
## Relationship Endpoints
|
|
183
185
|
|
|
@@ -96,12 +96,12 @@ module JSONAPI
|
|
|
96
96
|
RelationshipHelpers.polymorphic_association?(@resource_class, @relationship_name)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
# The field-list gate comes first, so it covers an attachment too.
|
|
99
100
|
def ensure_relationship_writable!(association)
|
|
100
|
-
return if active_storage_writable?(association)
|
|
101
|
-
|
|
102
101
|
unless @resource_class.relationship_field_writable?(@relationship_name, :update)
|
|
103
102
|
raise JSONAPI::AuthorizationError, "Relationship '#{@relationship_name}' is not updatable"
|
|
104
103
|
end
|
|
104
|
+
return if active_storage_writable?(association)
|
|
105
105
|
|
|
106
106
|
relationship_def = find_relationship_definition
|
|
107
107
|
readonly = relationship_def && (relationship_def[:options] || {})[:readonly] == true
|
|
@@ -115,12 +115,16 @@ module JSONAPI
|
|
|
115
115
|
self.class.active_storage_attachment?(association_name, @model_class)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
+
# An attachment passes the same field-list gate as a relationship. It has no association
|
|
119
|
+
# reflection, so the readonly check after the gate does not apply to it.
|
|
118
120
|
def ensure_relationship_writable!(association_name)
|
|
119
|
-
|
|
121
|
+
field_writable = @definition.relationship_field_writable?(association_name, @action)
|
|
122
|
+
if active_storage_attachment?(association_name)
|
|
123
|
+
return JSONAPI::RelationshipGuard.ensure_writable!(nil, association_name, field_writable:)
|
|
124
|
+
end
|
|
120
125
|
|
|
121
126
|
association = @model_class.reflect_on_association(association_name.to_sym)
|
|
122
127
|
readonly = relationship_options_for(association_name)[:readonly] == true
|
|
123
|
-
field_writable = @definition.relationship_field_writable?(association_name, @action)
|
|
124
128
|
JSONAPI::RelationshipGuard.ensure_writable!(association, association_name, readonly:, field_writable:)
|
|
125
129
|
end
|
|
126
130
|
|
data/lib/json_api/version.rb
CHANGED