Class: Spid::Rack::Login::LoginEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/spid/rack/login.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ LoginEnv

Returns a new instance of LoginEnv.



25
26
27
28
# File 'lib/spid/rack/login.rb', line 25

def initialize(env)
  @env = env
  @request = ::Rack::Request.new(env)
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



23
24
25
# File 'lib/spid/rack/login.rb', line 23

def env
  @env
end

#requestObject (readonly)

Returns the value of attribute request.



23
24
25
# File 'lib/spid/rack/login.rb', line 23

def request
  @request
end

Instance Method Details

#attribute_consuming_service_indexObject



88
89
90
# File 'lib/spid/rack/login.rb', line 88

def attribute_consuming_service_index
  request.params["attribute_index"] || "0"
end

#authn_contextObject



84
85
86
# File 'lib/spid/rack/login.rb', line 84

def authn_context
  request.params["authn_context"] || Spid::L1
end

#idp_nameObject



80
81
82
# File 'lib/spid/rack/login.rb', line 80

def idp_name
  request.params["idp_name"]
end

#log_messageObject



92
93
94
95
96
# File 'lib/spid/rack/login.rb', line 92

def log_message
  return nil unless Spid.configuration.logging_enabled

  Spid.configuration.logger.info responser.saml_message.delete("\n")
end

#relay_stateObject



70
71
72
73
# File 'lib/spid/rack/login.rb', line 70

def relay_state
  request.params["relay_state"] ||
    Spid.configuration.default_relay_state_path
end

#relay_state_idObject



75
76
77
78
# File 'lib/spid/rack/login.rb', line 75

def relay_state_id
  digest = Digest::MD5.hexdigest(relay_state)
  "_#{digest}"
end

#responseObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/spid/rack/login.rb', line 34

def response
  session["sso_request_uuid"] = responser.uuid
  session["relay_state"] = { relay_state_id => relay_state }
  session["idp"] = idp_name

  log_message
  [
    302, { "Location" => sso_url }, []
  ]
end

#responserObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/spid/rack/login.rb', line 49

def responser
  @responser ||=
    begin
      Spid::Sso::Request.new(
        idp_name: idp_name,
        relay_state: relay_state_id,
        attribute_index: attribute_consuming_service_index,
        authn_context: authn_context
      )
    end
end

#sessionObject



30
31
32
# File 'lib/spid/rack/login.rb', line 30

def session
  request.session["spid"]
end

#sso_urlObject



45
46
47
# File 'lib/spid/rack/login.rb', line 45

def sso_url
  responser.url
end

#valid_path?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/spid/rack/login.rb', line 66

def valid_path?
  request.path == Spid.configuration.
end

#valid_request?Boolean

Returns:

  • (Boolean)


61
62
63
64
# File 'lib/spid/rack/login.rb', line 61

def valid_request?
  valid_path? &&
    !idp_name.nil?
end