Class: SAML::UserAttributes::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/saml/user_attributes/base.rb

Constant Summary collapse

REQUIRED_ATTRIBUTES =
%i[email uuid idme_uuid sec_id loa sign_in multifactor].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(saml_attributes, authn_context, tracker_uuid) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
# File 'lib/saml/user_attributes/base.rb', line 10

def initialize(saml_attributes, authn_context, tracker_uuid)
  @attributes = saml_attributes # never default this to {}
  @authn_context = authn_context
  @tracker_uuid = tracker_uuid
  @warnings = []
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



8
9
10
# File 'lib/saml/user_attributes/base.rb', line 8

def attributes
  @attributes
end

#authn_contextObject (readonly)

Returns the value of attribute authn_context.



8
9
10
# File 'lib/saml/user_attributes/base.rb', line 8

def authn_context
  @authn_context
end

#tracker_uuidObject (readonly)

Returns the value of attribute tracker_uuid.



8
9
10
# File 'lib/saml/user_attributes/base.rb', line 8

def tracker_uuid
  @tracker_uuid
end

#warningsObject (readonly)

Returns the value of attribute warnings.



8
9
10
# File 'lib/saml/user_attributes/base.rb', line 8

def warnings
  @warnings
end

Instance Method Details

#common_nameObject



36
37
38
# File 'lib/saml/user_attributes/base.rb', line 36

def common_name
  email
end

#emailObject

ID.me email address associated with the signed-in ‘wallet’



32
33
34
# File 'lib/saml/user_attributes/base.rb', line 32

def email
  attributes['email']
end

#idme_loaObject

ID.me level of assurance, provided by all authn_contexts



41
42
43
# File 'lib/saml/user_attributes/base.rb', line 41

def idme_loa
  attributes['level_of_assurance']&.to_i
end

#idme_uuidObject



23
24
25
# File 'lib/saml/user_attributes/base.rb', line 23

def idme_uuid
  attributes['uuid']
end

#loaObject

This field is derived from methods implemented on child classes



51
52
53
# File 'lib/saml/user_attributes/base.rb', line 51

def loa
  { current: loa_current, highest: loa_highest }
end

#multifactorObject

ID.me boolean value that specifies whether the signed-in ‘wallet’ has multifactor enabled or not



46
47
48
# File 'lib/saml/user_attributes/base.rb', line 46

def multifactor
  attributes['multifactor']
end

#sec_idObject



27
28
29
# File 'lib/saml/user_attributes/base.rb', line 27

def sec_id
  nil
end

#sign_inObject

This includes service_name used to sign-in initially, and the account type that is associated with the sign in.



56
57
58
59
60
61
62
# File 'lib/saml/user_attributes/base.rb', line 56

def 
  SAML::User::AUTHN_CONTEXTS.fetch(authn_context)
                            .fetch(:sign_in)
                            .merge(account_type:)
rescue
  { service_name: 'unknown', account_type: 'N/A' }
end

#to_hashObject



64
65
66
# File 'lib/saml/user_attributes/base.rb', line 64

def to_hash
  serializable_attributes.index_with { |k| send(k) }
end

#uuidObject

Common Attributes ID.me unique identifier



19
20
21
# File 'lib/saml/user_attributes/base.rb', line 19

def uuid
  idme_uuid
end

#validate!Object

Raise any fatal exceptions due to validation issues



69
# File 'lib/saml/user_attributes/base.rb', line 69

def validate!; end