atlas_rb 1.24.0 → 1.25.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/.version +1 -1
- data/CHANGELOG.md +31 -0
- data/Gemfile.lock +1 -1
- data/lib/atlas_rb/person.rb +39 -5
- data/lib/atlas_rb/user.rb +15 -10
- 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: 2274a10469db90f642ca79a877ab37f9db69c294c55737a28824885249ef6220
|
|
4
|
+
data.tar.gz: c16a9865aa30a521823c17587e80179e681fab4a9c3747957ab0b943e8591548
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbf77b86e3b695401be85f2f913d4c71820ae2e1c2078884d6b13038d46cca749aaafaf7ef588e9f742db01e8b53b5375734893572430a9ccc7adbfed5444e50
|
|
7
|
+
data.tar.gz: baf502af151908b4da14e4e51597d60f7c88b90d7659deac2731bd44dc317376dce11bbb8e2c2e9f3d7fbfc33adc0e8b6572124769651e7917bfb51eaaac76b5
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.25.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.25.0
|
|
4
|
+
|
|
5
|
+
These bindings need Atlas 0.6.214 or later.
|
|
6
|
+
|
|
7
|
+
### Added — `q:` on `Person.list`, and `Person.page`
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
AtlasRb::Person.list(q: "gasp", nuid: admin_nuid)
|
|
11
|
+
result = AtlasRb::Person.page(q: "doe", page: 2, per_page: 50, nuid: admin_nuid)
|
|
12
|
+
result.pagination["count"] # => matches across every page
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`q:` searches the People registry. Atlas returns the Persons whose
|
|
16
|
+
`display_name` contains the fragment, whose NUID starts with it, or whose
|
|
17
|
+
account email contains it, all case-insensitive and ordered by `display_name`.
|
|
18
|
+
The search is admin-only. Anyone else gets a `403`, which raises
|
|
19
|
+
`ResourceError`.
|
|
20
|
+
|
|
21
|
+
`Person.page` takes the same arguments as `Person.list` and returns
|
|
22
|
+
`{ "people" => [...], "pagination" => {...} }`, so a caller can show a page
|
|
23
|
+
count and a total. With `q:`, the block counts the matches. `Person.list`
|
|
24
|
+
still returns the rows alone.
|
|
25
|
+
|
|
26
|
+
### Documented — `display_name` on the user directory
|
|
27
|
+
|
|
28
|
+
`User.search`, `User.resolve` and `User.find_by_nuid` entries now carry
|
|
29
|
+
`display_name`: the librarian-curated Person name for the NUID, or `nil` when
|
|
30
|
+
there is no Person. `User.search` also matches on it, and Atlas orders entries
|
|
31
|
+
by `display_name` when set, else `name`. No code changed: the gem already
|
|
32
|
+
passes the whole entry through.
|
|
33
|
+
|
|
3
34
|
## 1.24.0
|
|
4
35
|
|
|
5
36
|
These bindings need Atlas 0.6.213 or later.
|
data/Gemfile.lock
CHANGED
data/lib/atlas_rb/person.rb
CHANGED
|
@@ -20,8 +20,8 @@ module AtlasRb
|
|
|
20
20
|
# keep their usual gem meaning (the acting principal). NUID stays the key only
|
|
21
21
|
# for {.create} (one Person per NUID — and there `nuid:` is the *new person's*
|
|
22
22
|
# NUID, acting principal coming from the ambient `AtlasRb.config.default_nuid`)
|
|
23
|
-
# and {.resolve} (the server-side name-resolution batch). {.list}
|
|
24
|
-
# NOID-keyed People-index source.
|
|
23
|
+
# and {.resolve} (the server-side name-resolution batch). {.list} and
|
|
24
|
+
# {.page} are the NOID-keyed People-index source.
|
|
25
25
|
#
|
|
26
26
|
# Create / update / affiliation writes are :system + admin on the server; a
|
|
27
27
|
# non-privileged caller gets a 403.
|
|
@@ -50,6 +50,14 @@ module AtlasRb
|
|
|
50
50
|
# through atlas_rb without
|
|
51
51
|
# routing People through the catalog/Solr or exposing a NUID publicly.
|
|
52
52
|
#
|
|
53
|
+
# Pass `q:` to search: Atlas returns the Persons whose `display_name`
|
|
54
|
+
# contains the fragment, whose NUID starts with it, or whose account email
|
|
55
|
+
# contains it, all case-insensitive and ordered by `display_name`. The
|
|
56
|
+
# search is admin-only; anyone else gets a `403`. Use {.page} for the
|
|
57
|
+
# match count.
|
|
58
|
+
#
|
|
59
|
+
# @param q [String, nil] typeahead fragment (admin only). Blank lists
|
|
60
|
+
# everyone.
|
|
53
61
|
# @param page [Integer, nil] 1-based page (server default when nil).
|
|
54
62
|
# @param per_page [Integer, nil] page size (server default when nil; capped
|
|
55
63
|
# server-side).
|
|
@@ -62,10 +70,36 @@ module AtlasRb
|
|
|
62
70
|
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
63
71
|
# (an auth or validation envelope, a `5xx`, a proxy's `503`), carrying
|
|
64
72
|
# Atlas's status and body so the failure is attributable at the boundary.
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
# @example Admin typeahead
|
|
74
|
+
# AtlasRb::Person.list(q: "gasp", nuid: admin_nuid)
|
|
75
|
+
def self.list(q: nil, page: nil, per_page: nil, nuid: nil, on_behalf_of: nil)
|
|
76
|
+
self.page(q: q, page: page, per_page: per_page, nuid: nuid, on_behalf_of: on_behalf_of)&.people
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# One page of the People index with its pagination block — {.list} with
|
|
80
|
+
# the counts kept, for a consumer that shows "page 2 of 7" or a total.
|
|
81
|
+
# With `q:`, the block counts the matches, not the whole registry.
|
|
82
|
+
#
|
|
83
|
+
# @param q [String, nil] typeahead fragment (admin only), as on {.list}.
|
|
84
|
+
# @param page [Integer, nil] 1-based page (server default when nil).
|
|
85
|
+
# @param per_page [Integer, nil] page size (server default when nil; capped
|
|
86
|
+
# server-side).
|
|
87
|
+
# @param nuid [String, nil] acting principal.
|
|
88
|
+
# @param on_behalf_of [String, nil] acting-as target.
|
|
89
|
+
# @return [AtlasRb::Mash, nil] `{ "people" => [...], "pagination" => {...} }`,
|
|
90
|
+
# each `"people"` entry in the {.list} row shape.
|
|
91
|
+
# `nil` when Atlas answers `404` — nothing is there to read, or, with a
|
|
92
|
+
# misconfigured `ATLAS_URL`, the route is not Atlas's at all.
|
|
93
|
+
# @raise [AtlasRb::ResourceError] on any non-2xx other than `404` / `410`
|
|
94
|
+
# (an auth or validation envelope, a `5xx`, a proxy's `503`), carrying
|
|
95
|
+
# Atlas's status and body so the failure is attributable at the boundary.
|
|
96
|
+
# @example
|
|
97
|
+
# result = AtlasRb::Person.page(q: "doe", page: 2, per_page: 50, nuid: admin_nuid)
|
|
98
|
+
# result.pagination["count"] # => matches across every page (Hash#count shadows .count)
|
|
99
|
+
def self.page(q: nil, page: nil, per_page: nil, nuid: nil, on_behalf_of: nil)
|
|
100
|
+
params = { q: q, page: page, per_page: per_page }.compact
|
|
67
101
|
read_body(connection(params, nuid, on_behalf_of: on_behalf_of).get(ROUTE)) do |body|
|
|
68
|
-
|
|
102
|
+
AtlasRb::Mash.new(body)
|
|
69
103
|
end
|
|
70
104
|
end
|
|
71
105
|
|
data/lib/atlas_rb/user.rb
CHANGED
|
@@ -14,7 +14,9 @@ module AtlasRb
|
|
|
14
14
|
# logged-in-user capabilities.
|
|
15
15
|
#
|
|
16
16
|
# The directory lookups enforce minimal disclosure: every entry carries
|
|
17
|
-
# `nuid`
|
|
17
|
+
# `nuid`, `name` and `display_name` only (no email, role, or groups). `name`
|
|
18
|
+
# is the SSO-fed account name; `display_name` is the librarian-curated Person
|
|
19
|
+
# name for that NUID, or `nil` when the NUID has no Person. Rows with role
|
|
18
20
|
# `anonymous`, `guest`, or `system` are never returned. The account methods
|
|
19
21
|
# ({.accounts} / {.set_preferred}) *do* disclose email/groups/affiliation, so
|
|
20
22
|
# Atlas limits them to the person themselves (matching NUID), an admin, or the
|
|
@@ -30,16 +32,18 @@ module AtlasRb
|
|
|
30
32
|
|
|
31
33
|
# Typeahead search of the user directory.
|
|
32
34
|
#
|
|
33
|
-
# Case-insensitive match on
|
|
34
|
-
#
|
|
35
|
-
#
|
|
35
|
+
# Case-insensitive match on the account `name` or the curated
|
|
36
|
+
# `display_name`, prefix match on NUID (so typing a known NUID works too).
|
|
37
|
+
# Atlas caps the result (10 entries) and orders it by the name an entry
|
|
38
|
+
# shows — `display_name` when set, else `name`; a blank query resolves to
|
|
39
|
+
# an empty list.
|
|
36
40
|
#
|
|
37
41
|
# @param query [String] name fragment or NUID prefix to match.
|
|
38
42
|
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
39
43
|
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
40
44
|
# path it is ignored (identity lives in the token).
|
|
41
45
|
# @return [Array<AtlasRb::Mash>, nil] matching directory entries, each
|
|
42
|
-
# carrying `nuid` and `
|
|
46
|
+
# carrying `nuid`, `name` and `display_name` (`nil` without a Person).
|
|
43
47
|
#
|
|
44
48
|
# `nil` when Atlas answers `404` — nothing is there to read, or, with a
|
|
45
49
|
# misconfigured `ATLAS_URL`, the route is not Atlas's at all.
|
|
@@ -48,7 +52,7 @@ module AtlasRb
|
|
|
48
52
|
# Atlas's status and body so the failure is attributable at the boundary.
|
|
49
53
|
# @example Recipient typeahead
|
|
50
54
|
# AtlasRb::User.search("jan", nuid: "000000002")
|
|
51
|
-
# # => [{ "nuid" => "001234567", "name" => "Doe, Jane" }, ...]
|
|
55
|
+
# # => [{ "nuid" => "001234567", "name" => "Doe, Jane", "display_name" => "Jane Doe" }, ...]
|
|
52
56
|
def self.search(query, nuid: nil)
|
|
53
57
|
read_body(connection({ q: query }, nuid).get(ROUTE)) do |body|
|
|
54
58
|
body.map { |entry| AtlasRb::Mash.new(entry) }
|
|
@@ -62,7 +66,8 @@ module AtlasRb
|
|
|
62
66
|
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
63
67
|
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
64
68
|
# path it is ignored (identity lives in the token).
|
|
65
|
-
# @return [AtlasRb::Mash, nil] the `nuid
|
|
69
|
+
# @return [AtlasRb::Mash, nil] the `nuid`, `name` and `display_name`
|
|
70
|
+
# entry (`display_name` is `nil` without a Person), or `nil` when
|
|
66
71
|
# Atlas reports the NUID as absent (unknown, or held by an excluded
|
|
67
72
|
# role — the two are indistinguishable on the wire by design).
|
|
68
73
|
#
|
|
@@ -71,7 +76,7 @@ module AtlasRb
|
|
|
71
76
|
# Atlas's status and body so the failure is attributable at the boundary.
|
|
72
77
|
# @example Sender-name display
|
|
73
78
|
# AtlasRb::User.find_by_nuid("001234567")
|
|
74
|
-
# # => { "nuid" => "001234567", "name" => "Doe, Jane" }
|
|
79
|
+
# # => { "nuid" => "001234567", "name" => "Doe, Jane", "display_name" => "Jane Doe" }
|
|
75
80
|
def self.find_by_nuid(target_nuid, nuid: nil)
|
|
76
81
|
read_body(connection({}, nuid).get("#{ROUTE}/by_nuid/#{target_nuid}")) do |body|
|
|
77
82
|
AtlasRb::Mash.new(body)
|
|
@@ -88,8 +93,8 @@ module AtlasRb
|
|
|
88
93
|
# @param nuid [String, nil] optional acting user's NUID. On the relay-signing
|
|
89
94
|
# path it is signed into the assertion `sub`; on the BYO-JWT (`ATLAS_JWT`)
|
|
90
95
|
# path it is ignored (identity lives in the token).
|
|
91
|
-
# @return [Array<AtlasRb::Mash>, nil] resolved entries, each carrying `nuid
|
|
92
|
-
# and `
|
|
96
|
+
# @return [Array<AtlasRb::Mash>, nil] resolved entries, each carrying `nuid`,
|
|
97
|
+
# `name` and `display_name`, ordered by the name an entry shows.
|
|
93
98
|
#
|
|
94
99
|
# `nil` when Atlas answers `404` — nothing is there to read, or, with a
|
|
95
100
|
# misconfigured `ATLAS_URL`, the route is not Atlas's at all.
|