Class: Spid::Sso::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/spid/sso/request.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(idp_name:, attribute_index:, relay_state: nil, authn_context: nil) ⇒ Request

Returns a new instance of Request.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/spid/sso/request.rb', line 12

def initialize(
      idp_name:,
      attribute_index:,
      relay_state: nil,
      authn_context: nil
    )
  @idp_name = idp_name
  @relay_state = relay_state
  @authn_context = authn_context || Spid::L1
  @attribute_index = attribute_index
  @relay_state =
    begin
      relay_state || Spid.configuration.default_relay_state_path
    end
end

Instance Attribute Details

#attribute_indexObject (readonly)

Returns the value of attribute attribute_index.



8
9
10
# File 'lib/spid/sso/request.rb', line 8

def attribute_index
  @attribute_index
end

#authn_contextObject (readonly)

Returns the value of attribute authn_context.



9
10
11
# File 'lib/spid/sso/request.rb', line 9

def authn_context
  @authn_context
end

#authn_context_comparisonObject (readonly)

Returns the value of attribute authn_context_comparison.



10
11
12
# File 'lib/spid/sso/request.rb', line 10

def authn_context_comparison
  @authn_context_comparison
end

#idp_nameObject (readonly)

Returns the value of attribute idp_name.



6
7
8
# File 'lib/spid/sso/request.rb', line 6

def idp_name
  @idp_name
end

#relay_stateObject (readonly)

Returns the value of attribute relay_state.



7
8
9
# File 'lib/spid/sso/request.rb', line 7

def relay_state
  @relay_state
end

Instance Method Details

#authn_requestObject



55
56
57
# File 'lib/spid/sso/request.rb', line 55

def authn_request
  @authn_request ||= Spid::Saml2::AuthnRequest.new(settings: settings)
end

#identity_providerObject



68
69
70
71
# File 'lib/spid/sso/request.rb', line 68

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

#query_params_signerObject



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/spid/sso/request.rb', line 39

def query_params_signer
  @query_params_signer ||=
    begin
      Spid::Saml2::Utils::QueryParamsSigner.new(
        saml_message: saml_message,
        relay_state: relay_state,
        private_key: settings.private_key,
        signature_method: settings.signature_method
      )
    end
end

#saml_messageObject



51
52
53
# File 'lib/spid/sso/request.rb', line 51

def saml_message
  @saml_message ||= authn_request.to_saml
end

#service_providerObject



73
74
75
76
# File 'lib/spid/sso/request.rb', line 73

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

#settingsObject



59
60
61
62
63
64
65
66
# File 'lib/spid/sso/request.rb', line 59

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

#urlObject



28
29
30
31
32
33
# File 'lib/spid/sso/request.rb', line 28

def url
  [
    settings.idp_sso_target_url,
    query_params_signer.escaped_signed_query_string
  ].join("?")
end

#uuidObject



35
36
37
# File 'lib/spid/sso/request.rb', line 35

def uuid
  authn_request.uuid
end