Class: AtlasRb::Authentication
- Inherits:
-
Object
- Object
- AtlasRb::Authentication
- Extended by:
- FaradayHelper
- Defined in:
- lib/atlas_rb/authentication.rb
Overview
User-facing identity lookups against the Atlas API.
Unlike the resource classes, Authentication threads a real NUID into the
User header via FaradayHelper#connection's second positional argument.
The Atlas server uses that NUID — combined with the bearer token from
ATLAS_TOKEN — to resolve the acting user and their group memberships.
No login round-trip happens here today; the bearer token is assumed to be
already provisioned out-of-band. The commented-out code in this file
reflects an older flow where a /token endpoint exchanged an NUID for a
session token.
Class Method Summary collapse
-
.groups(nuid) ⇒ Array<Hash>
Fetch only the group memberships for an NUID.
-
.login(nuid) ⇒ Hash
Look up the Atlas user record for an NUID.
Methods included from FaradayHelper
Class Method Details
.groups(nuid) ⇒ Array<Hash>
Fetch only the group memberships for an NUID.
Convenience wrapper around the same GET /user call as login; useful
when authorization checks only need group names.
47 48 49 50 51 52 53 |
# File 'lib/atlas_rb/authentication.rb', line 47 def self.groups(nuid) # user_details = login(nuid) # token = user_details[:token] ... # TODO - need to update atlas login to give back name, id, and token upon logging in # result = JSON.parse(connection({ token: token }).post('/users/2/groups')&.body)["user"]["groups"] JSON.parse(connection({}, nuid).get('/user')&.body)["groups"] end |
.login(nuid) ⇒ Hash
Look up the Atlas user record for an NUID.
29 30 31 32 33 |
# File 'lib/atlas_rb/authentication.rb', line 29 def self.login(nuid) # JSON.parse(connection({ nuid: nuid }).post('/token')&.body)["token"] # need hash - id, name, token => ... JSON.parse(connection({}, nuid).get('/user')&.body) end |