atlas_rb 0.0.88 → 0.0.89
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 +2 -2
- data/lib/atlas_rb/faraday_helper.rb +13 -9
- data/lib/atlas_rb/user.rb +44 -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: a987c6f2b9d67ba84bfb29752682c630a47d69e943af83d44f5957136b2ae680
|
|
4
|
+
data.tar.gz: 5b2eea6ac511508959d56be1d7dce4306a2187eba6eeb5e1e4556ed7efe3fc9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0279a6e5f20724c89a4e5bb31232e33c9860f4a28ee416a34539e279715e43c8229e436f41a696cc56d762049e4b69abde7a21ba72adaf687bebc5330044e8c
|
|
7
|
+
data.tar.gz: a480b47e2927b337e222d4890d5903b366acebfc27283d366d3967fb98c53a96a84ff039c590ba1a2d67751982c8dd379123a2ad86391e84cf4f937c30225956
|
data/.version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.89
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
atlas_rb (0.0.
|
|
4
|
+
atlas_rb (0.0.89)
|
|
5
5
|
faraday (~> 2.7)
|
|
6
6
|
faraday-follow_redirects (~> 0.3.0)
|
|
7
7
|
faraday-multipart (~> 1)
|
|
@@ -23,7 +23,7 @@ GEM
|
|
|
23
23
|
net-http (~> 0.5)
|
|
24
24
|
hashie (5.1.0)
|
|
25
25
|
logger
|
|
26
|
-
json (2.19.
|
|
26
|
+
json (2.19.5)
|
|
27
27
|
logger (1.7.0)
|
|
28
28
|
multipart-post (2.4.1)
|
|
29
29
|
net-http (0.9.1)
|
|
@@ -29,14 +29,16 @@ module AtlasRb
|
|
|
29
29
|
# @example Fetching a community
|
|
30
30
|
# AtlasRb::Community.connection({}).get('/communities/abc123')
|
|
31
31
|
def connection(params, nuid=nil)
|
|
32
|
+
headers = {
|
|
33
|
+
"Content-Type" => "application/json",
|
|
34
|
+
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}"
|
|
35
|
+
}
|
|
36
|
+
headers["User"] = "NUID #{nuid}" if nuid
|
|
37
|
+
|
|
32
38
|
Faraday.new(
|
|
33
39
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
34
40
|
params: params,
|
|
35
|
-
headers:
|
|
36
|
-
"Content-Type" => "application/json",
|
|
37
|
-
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}",
|
|
38
|
-
"User" => "NUID #{nuid}"
|
|
39
|
-
}
|
|
41
|
+
headers: headers
|
|
40
42
|
) do |f|
|
|
41
43
|
f.response :follow_redirects
|
|
42
44
|
f.adapter Faraday.default_adapter
|
|
@@ -62,12 +64,14 @@ module AtlasRb
|
|
|
62
64
|
# }
|
|
63
65
|
# AtlasRb::Blob.multipart({}).post('/files/', payload)
|
|
64
66
|
def multipart(nuid=nil)
|
|
67
|
+
headers = {
|
|
68
|
+
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}"
|
|
69
|
+
}
|
|
70
|
+
headers["User"] = "NUID #{nuid}" if nuid
|
|
71
|
+
|
|
65
72
|
Faraday.new(
|
|
66
73
|
url: ENV.fetch("ATLAS_URL", nil),
|
|
67
|
-
headers:
|
|
68
|
-
"Authorization" => "Bearer #{ENV.fetch("ATLAS_TOKEN", nil)}",
|
|
69
|
-
"User" => "NUID #{nuid}"
|
|
70
|
-
}
|
|
74
|
+
headers: headers
|
|
71
75
|
) do |f|
|
|
72
76
|
f.request :multipart
|
|
73
77
|
f.request :url_encoded
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AtlasRb
|
|
4
|
+
# System-user binding for Atlas's find-or-create + group-replace endpoint.
|
|
5
|
+
#
|
|
6
|
+
# Used by Cerberus on its SSO callback: given an NUID and the IdP-asserted
|
|
7
|
+
# group set, find-or-create the matching User row and replace its groups
|
|
8
|
+
# with the supplied array (full replace, not merge — the IdP's assertion
|
|
9
|
+
# is authoritative).
|
|
10
|
+
#
|
|
11
|
+
# The endpoint is system-only; {.find_or_create} sends bearer-token auth
|
|
12
|
+
# and no `User:` header. Atlas returns 403 if any `User:` header is
|
|
13
|
+
# present.
|
|
14
|
+
class User
|
|
15
|
+
extend AtlasRb::FaradayHelper
|
|
16
|
+
|
|
17
|
+
# Find-or-create the User keyed on NUID and replace its groups.
|
|
18
|
+
#
|
|
19
|
+
# Idempotent on `nuid`. Authoritative on `groups`.
|
|
20
|
+
#
|
|
21
|
+
# @param nuid [String] the Northeastern University ID.
|
|
22
|
+
# @param groups [Array<String>] full group set; replaces, not merges.
|
|
23
|
+
# @param name [String, nil] forwarded if the caller (e.g. Cerberus's
|
|
24
|
+
# SSO callback) has it; Atlas treats this field as optional.
|
|
25
|
+
# @param email [String, nil] forwarded if available; optional in Atlas.
|
|
26
|
+
# @return [AtlasRb::Mash] the resulting User record (`id`, `nuid`,
|
|
27
|
+
# `name`, `email`, `role`, `groups`).
|
|
28
|
+
#
|
|
29
|
+
# @example From Cerberus's SSO callback
|
|
30
|
+
# AtlasRb::User.find_or_create(nuid: "001234567",
|
|
31
|
+
# groups: ["northeastern:staff",
|
|
32
|
+
# "drs:editors"],
|
|
33
|
+
# name: "Jane Doe",
|
|
34
|
+
# email: "j.doe@example.edu")
|
|
35
|
+
def self.find_or_create(nuid:, groups:, name: nil, email: nil)
|
|
36
|
+
body = { groups: groups }
|
|
37
|
+
body[:name] = name if name
|
|
38
|
+
body[:email] = email if email
|
|
39
|
+
|
|
40
|
+
response = connection({}).put("/users/by_nuid/#{nuid}", body.to_json)
|
|
41
|
+
AtlasRb::Mash.new(JSON.parse(response.body))["user"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/lib/atlas_rb.rb
CHANGED
|
@@ -13,6 +13,7 @@ require_relative "atlas_rb/collection"
|
|
|
13
13
|
require_relative "atlas_rb/work"
|
|
14
14
|
require_relative "atlas_rb/file_set"
|
|
15
15
|
require_relative "atlas_rb/blob"
|
|
16
|
+
require_relative "atlas_rb/user"
|
|
16
17
|
|
|
17
18
|
# Ruby client for the Atlas API — Northeastern University's institutional
|
|
18
19
|
# digital repository.
|
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: 0.0.
|
|
4
|
+
version: 0.0.89
|
|
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-
|
|
11
|
+
date: 2026-05-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -122,6 +122,7 @@ files:
|
|
|
122
122
|
- lib/atlas_rb/file_set.rb
|
|
123
123
|
- lib/atlas_rb/mash.rb
|
|
124
124
|
- lib/atlas_rb/resource.rb
|
|
125
|
+
- lib/atlas_rb/user.rb
|
|
125
126
|
- lib/atlas_rb/version.rb
|
|
126
127
|
- lib/atlas_rb/work.rb
|
|
127
128
|
- sig/atlas_rb.rbs
|