Class: AtlasRb::System::User
- Inherits:
-
Object
- Object
- AtlasRb::System::User
- Extended by:
- FaradayHelper
- Defined in:
- lib/atlas_rb/system/user.rb
Overview
SSO-callback user provisioning. Finds the Atlas User row keyed on
the supplied email — the account key — (creating it if missing) and
replaces its groups with the IdP-asserted set. Full replace, not
merge — the IdP assertion is authoritative. Keying on email keeps a
person's staff/student logins as distinct accounts under one NUID.
Always authenticates via FaradayHelper#system_connection, so the caller has no way to act as a non-system principal. Atlas allows this endpoint only for the system token + system NUID pairing.
Constant Summary
Constants included from FaradayHelper
FaradayHelper::ASSERTION_AUDIENCE, FaradayHelper::ASSERTION_ISSUER, FaradayHelper::ASSERTION_TTL, FaradayHelper::INSTRUMENTATION_EVENT
Class Method Summary collapse
-
.find_or_create(email:, nuid: nil, groups: [], name: nil, affiliation: nil) ⇒ AtlasRb::Mash
Find-or-create the User keyed on email and replace its groups.
Methods included from FaradayHelper
connection, multipart, system_connection, with_file_part
Class Method Details
.find_or_create(email:, nuid: nil, groups: [], name: nil, affiliation: nil) ⇒ AtlasRb::Mash
Find-or-create the User keyed on email and replace its groups.
Email is the account key: a person's staff and student logins share a NUID but present a different email each, so keying on email keeps them as distinct accounts instead of collapsing (last-write-wins) on NUID.
68 69 70 71 72 73 74 75 76 |
# File 'lib/atlas_rb/system/user.rb', line 68 def self.find_or_create(email:, nuid: nil, groups: [], name: nil, affiliation: nil) body = { groups: groups } body[:nuid] = nuid if nuid body[:name] = name if name body[:affiliation] = affiliation if affiliation response = system_connection.put("/users/by_email/#{email}", body.to_json) AtlasRb::Mash.new(JSON.parse(response.body))["user"] end |