Class: Spid::Rack::Slo::SloEnv
- Inherits:
-
Object
- Object
- Spid::Rack::Slo::SloEnv
- Defined in:
- lib/spid/rack/slo.rb
Overview
rubocop:disable Metrics/ClassLength
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
:nodoc:.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
- #clear_session ⇒ Object
- #idp_initiated? ⇒ Boolean
-
#initialize(env) ⇒ SloEnv
constructor
A new instance of SloEnv.
- #relay_state ⇒ Object
- #relay_state_param ⇒ Object
- #request_relay_state ⇒ Object
- #response ⇒ Object
- #response_idp_initiated ⇒ Object
- #response_sp_initiated ⇒ Object
- #responser ⇒ Object
- #saml_request ⇒ Object
- #saml_response ⇒ Object
- #session ⇒ Object
- #store_session_failure ⇒ Object
- #valid_get? ⇒ Boolean
- #valid_http_verb? ⇒ Boolean
- #valid_path? ⇒ Boolean
- #valid_post? ⇒ Boolean
- #valid_request? ⇒ Boolean
- #valid_response? ⇒ Boolean
- #validate_session ⇒ Object
Constructor Details
#initialize(env) ⇒ SloEnv
Returns a new instance of SloEnv.
25 26 27 28 |
# File 'lib/spid/rack/slo.rb', line 25 def initialize(env) @env = env @request = ::Rack::Request.new(env) end |
Instance Attribute Details
#env ⇒ Object (readonly)
:nodoc:
22 23 24 |
# File 'lib/spid/rack/slo.rb', line 22 def env @env end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
23 24 25 |
# File 'lib/spid/rack/slo.rb', line 23 def request @request end |
Instance Method Details
#clear_session ⇒ Object
34 35 36 |
# File 'lib/spid/rack/slo.rb', line 34 def clear_session request.session["spid"] = {} end |
#idp_initiated? ⇒ Boolean
121 122 123 |
# File 'lib/spid/rack/slo.rb', line 121 def idp_initiated? !saml_request.nil? end |
#relay_state ⇒ Object
80 81 82 83 84 85 |
# File 'lib/spid/rack/slo.rb', line 80 def relay_state if request_relay_state.nil? return Spid.configuration.default_relay_state_path end session["relay_state"][relay_state_param] end |
#relay_state_param ⇒ Object
69 70 71 |
# File 'lib/spid/rack/slo.rb', line 69 def relay_state_param request.params["RelayState"] end |
#request_relay_state ⇒ Object
73 74 75 76 77 78 |
# File 'lib/spid/rack/slo.rb', line 73 def request_relay_state if !relay_state_param.nil? || relay_state_param != "" session["relay_state"][relay_state_param] end end |
#response ⇒ Object
62 63 64 65 66 67 |
# File 'lib/spid/rack/slo.rb', line 62 def response @relay_state = relay_state unless idp_initiated? validate_session return response_idp_initiated if idp_initiated? response_sp_initiated end |
#response_idp_initiated ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/spid/rack/slo.rb', line 50 def response_idp_initiated [ 200, {}, responser.response ] end |
#response_sp_initiated ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/spid/rack/slo.rb', line 42 def response_sp_initiated [ 302, { "Location" => @relay_state }, responser.response ] end |
#responser ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# File 'lib/spid/rack/slo.rb', line 125 def responser @responser ||= begin if idp_initiated? idp_initiated_slo_request else sp_initiated_slo_response end end end |
#saml_request ⇒ Object
117 118 119 |
# File 'lib/spid/rack/slo.rb', line 117 def saml_request request.params["SAMLRequest"] end |
#saml_response ⇒ Object
113 114 115 |
# File 'lib/spid/rack/slo.rb', line 113 def saml_response request.params["SAMLResponse"] end |
#session ⇒ Object
30 31 32 |
# File 'lib/spid/rack/slo.rb', line 30 def session request.session["spid"] end |
#store_session_failure ⇒ Object
38 39 40 |
# File 'lib/spid/rack/slo.rb', line 38 def store_session_failure session["errors"] = responser.errors end |
#valid_get? ⇒ Boolean
87 88 89 90 |
# File 'lib/spid/rack/slo.rb', line 87 def valid_get? request.get? && Spid.configuration.slo_binding == Spid::BINDINGS_HTTP_REDIRECT end |
#valid_http_verb? ⇒ Boolean
97 98 99 |
# File 'lib/spid/rack/slo.rb', line 97 def valid_http_verb? valid_post? || valid_get? end |
#valid_path? ⇒ Boolean
101 102 103 |
# File 'lib/spid/rack/slo.rb', line 101 def valid_path? request.path == Spid.configuration.slo_path end |
#valid_post? ⇒ Boolean
92 93 94 95 |
# File 'lib/spid/rack/slo.rb', line 92 def valid_post? request.post? && Spid.configuration.slo_binding == Spid::BINDINGS_HTTP_POST end |
#valid_request? ⇒ Boolean
109 110 111 |
# File 'lib/spid/rack/slo.rb', line 109 def valid_request? valid_path? && valid_http_verb? end |
#valid_response? ⇒ Boolean
105 106 107 |
# File 'lib/spid/rack/slo.rb', line 105 def valid_response? responser.valid? end |
#validate_session ⇒ Object
58 59 60 |
# File 'lib/spid/rack/slo.rb', line 58 def validate_session valid_response? ? clear_session : store_session_failure end |