Class: Spid::Rack::Logout::LogoutEnv

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ LogoutEnv

Returns a new instance of LogoutEnv.



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

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

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



21
22
23
# File 'lib/spid/rack/logout.rb', line 21

def env
  @env
end

#requestObject (readonly)

Returns the value of attribute request.



21
22
23
# File 'lib/spid/rack/logout.rb', line 21

def request
  @request
end

Instance Method Details

#idp_nameObject



82
83
84
# File 'lib/spid/rack/logout.rb', line 82

def idp_name
  request.params["idp_name"]
end

#relay_stateObject



72
73
74
75
# File 'lib/spid/rack/logout.rb', line 72

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

#relay_state_idObject



77
78
79
80
# File 'lib/spid/rack/logout.rb', line 77

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

#responseObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/spid/rack/logout.rb', line 28

def response
  session["slo_request_uuid"] = responser.uuid
  session["relay_state"] = {
    relay_state_id => relay_state
  }
  session["idp"] = idp_name
  [
    302, { "Location" => slo_url }, []
  ]
end

#responserObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/spid/rack/logout.rb', line 47

def responser
  @responser ||=
    begin
      Spid::Slo::Request.new(
        idp_name: idp_name,
        relay_state: relay_state_id,
        session_index: spid_session["session_index"]
      )
    end
end

#sessionObject



39
40
41
# File 'lib/spid/rack/logout.rb', line 39

def session
  request.session["spid"]
end

#slo_urlObject



43
44
45
# File 'lib/spid/rack/logout.rb', line 43

def slo_url
  responser.url
end

#spid_sessionObject



68
69
70
# File 'lib/spid/rack/logout.rb', line 68

def spid_session
  request.session["spid"]
end

#valid_path?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/spid/rack/logout.rb', line 64

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

#valid_request?Boolean

Returns:

  • (Boolean)


58
59
60
61
62
# File 'lib/spid/rack/logout.rb', line 58

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