Class: Spid::Sso::Response

Inherits:
Object
  • Object
show all
Includes:
Spid::Saml2::Utils
Defined in:
lib/spid/sso/response.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Spid::Saml2::Utils

#certificate_from_encoded_der, #decode, #decode_and_inflate, #deflate, #deflate_and_encode, #encode, #escaped_params, #escaped_query_string, #inflate, #query_param, #query_params, #query_string

Constructor Details

#initialize(body:, request_uuid:) ⇒ Response

Returns a new instance of Response.



15
16
17
18
19
# File 'lib/spid/sso/response.rb', line 15

def initialize(body:, request_uuid:)
  @body = body
  @saml_message = decode_and_inflate(body)
  @request_uuid = request_uuid
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



11
12
13
# File 'lib/spid/sso/response.rb', line 11

def body
  @body
end

#request_uuidObject (readonly)

Returns the value of attribute request_uuid.



13
14
15
# File 'lib/spid/sso/response.rb', line 13

def request_uuid
  @request_uuid
end

#saml_messageObject (readonly)

Returns the value of attribute saml_message.



12
13
14
# File 'lib/spid/sso/response.rb', line 12

def saml_message
  @saml_message
end

Instance Method Details

#attributesObject



42
43
44
45
46
# File 'lib/spid/sso/response.rb', line 42

def attributes
  raw_attributes.each_with_object({}) do |(key, value), acc|
    acc[normalize_key(key)] = value
  end
end

#errorsObject



38
39
40
# File 'lib/spid/sso/response.rb', line 38

def errors
  validator.errors
end

#identity_providerObject



56
57
58
59
# File 'lib/spid/sso/response.rb', line 56

def identity_provider
  @identity_provider ||=
    IdentityProviderManager.find_by_entity(issuer)
end

#issuerObject



34
35
36
# File 'lib/spid/sso/response.rb', line 34

def issuer
  saml_response.assertion_issuer
end

#raw_attributesObject



52
53
54
# File 'lib/spid/sso/response.rb', line 52

def raw_attributes
  saml_response.attributes
end

#saml_responseObject



66
67
68
# File 'lib/spid/sso/response.rb', line 66

def saml_response
  @saml_response ||= Spid::Saml2::Response.new(saml_message: saml_message)
end

#service_providerObject



61
62
63
64
# File 'lib/spid/sso/response.rb', line 61

def service_provider
  @service_provider ||=
    Spid.configuration.service_provider
end

#session_indexObject



48
49
50
# File 'lib/spid/sso/response.rb', line 48

def session_index
  saml_response.session_index
end

#settingsObject



70
71
72
73
74
75
# File 'lib/spid/sso/response.rb', line 70

def settings
  @settings ||= Spid::Saml2::Settings.new(
    identity_provider: identity_provider,
    service_provider: service_provider
  )
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/spid/sso/response.rb', line 21

def valid?
  validator.call
end

#validatorObject



25
26
27
28
29
30
31
32
# File 'lib/spid/sso/response.rb', line 25

def validator
  @validator ||=
    Spid::Saml2::ResponseValidator.new(
      response: saml_response,
      settings: settings,
      request_uuid: request_uuid
    )
end