jpie 4.2.0 → 4.3.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d86e3060510b7665640ceac854fe30f8dfe528b0da8210ff24078fbc547ad564
|
|
4
|
+
data.tar.gz: 455604febf5de122b7c348886144f81293da164c62dba2eb47ed7bef44dbe925
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2aed2419a62037f17e8f0fe799270b30b13ce556b8d1840588e9d8749c251cb684b33fafa980573f02171905770ec508d0d6277eea0839b09ace245ca02acd0a
|
|
7
|
+
data.tar.gz: f13a74becef4567cb576e0e0572ae1862c2c323e30c4b3c30dc4f45d4d75c1d1f084aac670b8cd732dcd9b3842d1fe37a489abfb922834e6769cdbc2275991a0
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ at release time.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.3.0] - 2026-11-25
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **Attach only a blob the caller may show.** A write body names a blob by its
|
|
15
|
+
signed id, under `relationships` or as a bare string under `attributes`. jpie
|
|
16
|
+
attached it with no authorization check, so a caller who held another
|
|
17
|
+
tenant's signed id attached that tenant's file and read it back. jpie now
|
|
18
|
+
resolves each named blob and calls `authorization_handler` with
|
|
19
|
+
`action: :show` on it before it writes the record. A refusal answers 403 and
|
|
20
|
+
writes nothing. An invalid signed id under `attributes` now answers 400
|
|
21
|
+
before an update writes the record, as it did under `relationships`. A value
|
|
22
|
+
that is neither a signed id nor a blob also answers 400 before the write.
|
|
23
|
+
Before, an update saved the record and purged the old file, then failed.
|
|
24
|
+
**Upgrade:** a handler that refuses `show` on an `ActiveStorage::Blob` now
|
|
25
|
+
also refuses the attach. Regression spec:
|
|
26
|
+
`attachment_blob_authorization_spec.rb`.
|
|
27
|
+
|
|
10
28
|
## [4.2.0] - 2026-11-24
|
|
11
29
|
|
|
12
30
|
### Changed
|
data/README.md
CHANGED
|
@@ -1031,6 +1031,8 @@ The gem automatically renders `403 Forbidden` for `JSONAPI::AuthorizationError`
|
|
|
1031
1031
|
|
|
1032
1032
|
Relationship endpoints authorize the parent resource with `action: :update` and `context: { relationship: :relationship_name }`.
|
|
1033
1033
|
|
|
1034
|
+
A create or update body that names an ActiveStorage blob, under `relationships` or as a signed id under `attributes`, authorizes each blob with `action: :show` before it writes the record. A caller attaches only a file it may read.
|
|
1035
|
+
|
|
1034
1036
|
## Instrumentation (Rails 8.1+)
|
|
1035
1037
|
|
|
1036
1038
|
When running on Rails 8.1 or later, the gem automatically emits structured events via `Rails.event` for all CRUD and relationship operations. This enables seamless integration with monitoring and APM platforms like Datadog, AppSignal, New Relic, or Honeycomb.
|
|
@@ -1912,9 +1914,12 @@ try {
|
|
|
1912
1914
|
Two paths publish the gem to rubygems.org:
|
|
1913
1915
|
|
|
1914
1916
|
- **Real release**: run `bin/release [major|minor|patch]` on a branch. The
|
|
1915
|
-
script bumps `lib/json_api/version.rb
|
|
1916
|
-
|
|
1917
|
-
|
|
1917
|
+
script bumps `lib/json_api/version.rb`, locks jpie at the new version in
|
|
1918
|
+
`Gemfile.lock`, and moves the "Unreleased" changelog entries under the new
|
|
1919
|
+
version with today's date. It commits the three files together, and stops
|
|
1920
|
+
when "Unreleased" holds no entry. Open a PR. When the bump lands on main, the
|
|
1921
|
+
`Release` workflow publishes the gem and pushes the `v<version>` tag. No OTP
|
|
1922
|
+
code is needed.
|
|
1918
1923
|
- **Nightly prerelease**: the `Nightly prerelease` workflow runs each night at
|
|
1919
1924
|
03:00 UTC. When main has commits that no release or nightly covers, it
|
|
1920
1925
|
publishes `<next-patch>.pre.<stamp>` (for example `3.10.1.pre.202608300300`).
|
|
@@ -19,7 +19,27 @@ module JSONAPI
|
|
|
19
19
|
hash = deserialize_params(:update, definition: @resource_class)
|
|
20
20
|
attachments = extract_active_storage_params_from_hash(hash, model_class)
|
|
21
21
|
clean_params(hash, attachments)
|
|
22
|
-
[hash, attachments]
|
|
22
|
+
[hash, authorize_attachment_blobs(attachments)]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# A client names a blob by its signed id, under `relationships` or as a bare string under
|
|
26
|
+
# `attributes`. The signature proves only that this application made the id, not that the
|
|
27
|
+
# caller may read the file. Resolve each named blob and ask the authorization handler to
|
|
28
|
+
# `show` it before the record is written, so a caller attaches only a file it may read.
|
|
29
|
+
# Any other value names no file to judge, so refuse it before the write too.
|
|
30
|
+
def authorize_attachment_blobs(attachments)
|
|
31
|
+
attachments.transform_values { authorize_attachment_value(it) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def authorize_attachment_value(value)
|
|
35
|
+
return value.map { authorize_attachment_value(it) } if value.is_a?(Array)
|
|
36
|
+
return value if value.blank?
|
|
37
|
+
|
|
38
|
+
blob = value.is_a?(String) ? find_blob_by_signed_id(value) : value
|
|
39
|
+
raise ArgumentError, "Expected a signed blob ID, got #{value.class}" unless blob.is_a?(::ActiveStorage::Blob)
|
|
40
|
+
|
|
41
|
+
authorize_resource_action!(blob, action: :show)
|
|
42
|
+
blob
|
|
23
43
|
end
|
|
24
44
|
|
|
25
45
|
def clean_params(hash, attachments)
|
|
@@ -58,7 +58,8 @@ module JSONAPI
|
|
|
58
58
|
def create
|
|
59
59
|
@resource = build_resource_for_create
|
|
60
60
|
authorize_resource_action!(@resource, action: :create)
|
|
61
|
-
|
|
61
|
+
attachments = authorize_attachment_blobs(@create_attachments)
|
|
62
|
+
attach_active_storage_files(@resource, attachments, resource_class: determine_sti_resource_class)
|
|
62
63
|
save_created(@resource)
|
|
63
64
|
rescue ArgumentError => e
|
|
64
65
|
render_create_error(e)
|
data/lib/json_api/version.rb
CHANGED