atlas_rb 1.9.0 → 1.9.1
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/.version +1 -1
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/faraday_helper.rb +8 -1
- data/lib/atlas_rb/system/work.rb +48 -0
- data/lib/atlas_rb.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe879cca7166684164dce3dc7651f22b68c83bd36d4463aaf70d1078147b26f8
|
|
4
|
+
data.tar.gz: ab88520172776ef649214806b30b2153d1804e960672e7c6ed4237a33ce9eb22
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89879f3e03444288baa4e04004bd83e706ace04652eca337cb85d7e665816d49d4ce2d006a598c3505317bff78106e647b477bcbd77fdd0408eda6c0632fa8ca
|
|
7
|
+
data.tar.gz: de9bf34fe94ff2192733ac5c21040b6b1dc8d1b941270398a8edfa0231d4c41fa5ccc69ba17cb68797b40c1a0c6263b187811200c9de13166543cd4bc9632bd8
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.9.
|
|
1
|
+
1.9.1
|
data/Gemfile.lock
CHANGED
|
@@ -196,11 +196,13 @@ module AtlasRb
|
|
|
196
196
|
# Used exclusively by classes under {AtlasRb::System}.
|
|
197
197
|
#
|
|
198
198
|
# @param params [Hash] query-string / body params.
|
|
199
|
+
# @param on_behalf_of [String, nil] optional NUID sent as a plain (not
|
|
200
|
+
# signed) `On-Behalf-Of` header — this path is already backend-only.
|
|
199
201
|
# @return [Faraday::Connection] a system-authenticated connection.
|
|
200
202
|
# @raise [RuntimeError] if the credential is not configured.
|
|
201
203
|
# @raise [NameError] if `Rails` is not loaded (the gem assumes a
|
|
202
204
|
# Rails host for system-path calls).
|
|
203
|
-
def system_connection(params = {})
|
|
205
|
+
def system_connection(params = {}, on_behalf_of: nil)
|
|
204
206
|
token = Rails.application.credentials.atlas_system_token ||
|
|
205
207
|
raise("atlas_rb: Rails.application.credentials.atlas_system_token not configured")
|
|
206
208
|
|
|
@@ -209,6 +211,7 @@ module AtlasRb
|
|
|
209
211
|
"Authorization" => "Bearer #{token}",
|
|
210
212
|
"User" => "NUID #{AtlasRb::System::NUID}"
|
|
211
213
|
}
|
|
214
|
+
headers["On-Behalf-Of"] = "NUID #{on_behalf_of}" if on_behalf_of
|
|
212
215
|
|
|
213
216
|
Faraday.new(
|
|
214
217
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
@@ -216,6 +219,10 @@ module AtlasRb
|
|
|
216
219
|
headers: headers
|
|
217
220
|
) do |f|
|
|
218
221
|
instrument(f)
|
|
222
|
+
# Narrowly path-scoped (see each class) — a no-op for System::User /
|
|
223
|
+
# System::Token, and gives System::Work the same typed errors as #connection.
|
|
224
|
+
f.use AtlasRb::Middleware::RaiseOnStaleResource
|
|
225
|
+
f.use AtlasRb::Middleware::RaiseOnResourceError
|
|
219
226
|
f.response :follow_redirects
|
|
220
227
|
f.adapter Faraday.default_adapter
|
|
221
228
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AtlasRb
|
|
4
|
+
module System
|
|
5
|
+
# Showcase publishing: link a freshly-created Work into a depositor's
|
|
6
|
+
# featured showcase Collection on their behalf, without granting the
|
|
7
|
+
# depositor themselves standing edit rights on that shared Collection.
|
|
8
|
+
#
|
|
9
|
+
# Atlas scopes this narrowly on both sides (see Atlas's `Ability`): the
|
|
10
|
+
# target Collection must be `featured`, and the Work must belong to the
|
|
11
|
+
# `on_behalf_of` NUID — never an arbitrary or private Work. Cerberus's
|
|
12
|
+
# `WorkDeposit#create_published` ("Publish to my community") is the one
|
|
13
|
+
# caller today.
|
|
14
|
+
#
|
|
15
|
+
# Always authenticates via {FaradayHelper#system_connection}, so there is
|
|
16
|
+
# no way to issue this as a regular user.
|
|
17
|
+
class Work
|
|
18
|
+
extend AtlasRb::FaradayHelper
|
|
19
|
+
|
|
20
|
+
# @param work_id [String] the Work ID to link.
|
|
21
|
+
# @param collection_id [String] the (must-be-featured) showcase
|
|
22
|
+
# Collection to link the Work into.
|
|
23
|
+
# @param on_behalf_of [String] the depositor NUID this write is
|
|
24
|
+
# attributed to — required (unlike the regular, human-facing
|
|
25
|
+
# {AtlasRb::Work.add_linked_member}), since a :system call with no
|
|
26
|
+
# attribution defeats the point of this path, and Atlas's Ability
|
|
27
|
+
# grant is itself conditioned on it matching the Work's depositor.
|
|
28
|
+
# @return [Array<String>] the Work's full set of linked Collection
|
|
29
|
+
# noids after the add.
|
|
30
|
+
# @raise [AtlasRb::StaleResourceError] optimistic-lock conflict.
|
|
31
|
+
# @raise [AtlasRb::LinkedMemberError] structural rejection (HTTP 422) —
|
|
32
|
+
# non-Collection target, tombstoned work/target, already a structural
|
|
33
|
+
# member.
|
|
34
|
+
# @raise [AtlasRb::ForbiddenError] Atlas refused the link (HTTP 403) —
|
|
35
|
+
# e.g. the target Collection isn't featured, or on_behalf_of doesn't
|
|
36
|
+
# own the Work.
|
|
37
|
+
#
|
|
38
|
+
# @example From Cerberus's publish-to-showcase deposit branch
|
|
39
|
+
# AtlasRb::System::Work.add_linked_member(work.id, showcase.id, on_behalf_of: depositor_nuid)
|
|
40
|
+
def self.add_linked_member(work_id, collection_id, on_behalf_of:)
|
|
41
|
+
JSON.parse(
|
|
42
|
+
system_connection({ collection_id: collection_id }, on_behalf_of: on_behalf_of)
|
|
43
|
+
.post("/works/#{work_id}/linked_members")&.body
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/atlas_rb.rb
CHANGED
|
@@ -31,6 +31,7 @@ require_relative "atlas_rb/admin/community"
|
|
|
31
31
|
require_relative "atlas_rb/system"
|
|
32
32
|
require_relative "atlas_rb/system/user"
|
|
33
33
|
require_relative "atlas_rb/system/token"
|
|
34
|
+
require_relative "atlas_rb/system/work"
|
|
34
35
|
require_relative "atlas_rb/audit_event"
|
|
35
36
|
|
|
36
37
|
# Ruby client for the Atlas API — Northeastern University's institutional
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: atlas_rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Cliff
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -152,6 +152,7 @@ files:
|
|
|
152
152
|
- lib/atlas_rb/system.rb
|
|
153
153
|
- lib/atlas_rb/system/token.rb
|
|
154
154
|
- lib/atlas_rb/system/user.rb
|
|
155
|
+
- lib/atlas_rb/system/work.rb
|
|
155
156
|
- lib/atlas_rb/user.rb
|
|
156
157
|
- lib/atlas_rb/version.rb
|
|
157
158
|
- lib/atlas_rb/work.rb
|