Class: Spid::Rack::Sso::SsoEnv
- Inherits:
-
Object
- Object
- Spid::Rack::Sso::SsoEnv
- Defined in:
- lib/spid/rack/sso.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(env) ⇒ SsoEnv
constructor
A new instance of SsoEnv.
- #log_message ⇒ Object
- #relay_state ⇒ Object
- #relay_state_param ⇒ Object
- #request_relay_state ⇒ Object
- #response ⇒ Object
- #responser ⇒ Object
- #saml_response ⇒ Object
- #session ⇒ Object
- #store_session_failure ⇒ Object
- #store_session_success ⇒ Object
- #valid_get? ⇒ Boolean
- #valid_http_verb? ⇒ Boolean
- #valid_path? ⇒ Boolean
- #valid_post? ⇒ Boolean
- #valid_request? ⇒ Boolean
- #valid_response? ⇒ Boolean
Constructor Details
#initialize(env) ⇒ SsoEnv
Returns a new instance of SsoEnv.
24 25 26 27 28 |
# File 'lib/spid/rack/sso.rb', line 24 def initialize(env) @env = env @request = ::Rack::Request.new(env) @relay_state = relay_state end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
21 22 23 |
# File 'lib/spid/rack/sso.rb', line 21 def env @env end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
22 23 24 |
# File 'lib/spid/rack/sso.rb', line 22 def request @request end |
Instance Method Details
#log_message ⇒ Object
117 118 119 120 121 |
# File 'lib/spid/rack/sso.rb', line 117 def return nil unless Spid.configuration.logging_enabled Spid.configuration.logger.info responser..delete("\n") end |
#relay_state ⇒ Object
77 78 79 80 81 82 |
# File 'lib/spid/rack/sso.rb', line 77 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
65 66 67 |
# File 'lib/spid/rack/sso.rb', line 65 def relay_state_param request.params["RelayState"] end |
#request_relay_state ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/spid/rack/sso.rb', line 69 def request_relay_state if !relay_state_param.nil? && relay_state_param != "" && !session["relay_state"].nil? session["relay_state"][relay_state_param] end end |
#response ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/spid/rack/sso.rb', line 49 def response if valid_response? store_session_success else store_session_failure end [ 302, { "Location" => @relay_state }, [] ] end |
#responser ⇒ Object
110 111 112 113 114 115 |
# File 'lib/spid/rack/sso.rb', line 110 def responser @responser ||= ::Spid::Sso::Response.new( body: saml_response, request_uuid: session["sso_request_uuid"] ) end |
#saml_response ⇒ Object
61 62 63 |
# File 'lib/spid/rack/sso.rb', line 61 def saml_response request.params["SAMLResponse"] end |
#session ⇒ Object
30 31 32 |
# File 'lib/spid/rack/sso.rb', line 30 def session request.session["spid"] end |
#store_session_failure ⇒ Object
42 43 44 45 46 47 |
# File 'lib/spid/rack/sso.rb', line 42 def store_session_failure session["errors"] = responser.errors session.delete("attributes") session.delete("sso_request_uuid") session.delete("session_index") end |
#store_session_success ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/spid/rack/sso.rb', line 34 def store_session_success session["attributes"] = responser.attributes session["session_index"] = responser.session_index session.delete("sso_request_uuid") session.delete("errors") session.delete("relay_state") end |
#valid_get? ⇒ Boolean
84 85 86 87 |
# File 'lib/spid/rack/sso.rb', line 84 def valid_get? request.get? && Spid.configuration.acs_binding == Spid::BINDINGS_HTTP_REDIRECT end |
#valid_http_verb? ⇒ Boolean
94 95 96 |
# File 'lib/spid/rack/sso.rb', line 94 def valid_http_verb? valid_get? || valid_post? end |
#valid_path? ⇒ Boolean
98 99 100 |
# File 'lib/spid/rack/sso.rb', line 98 def valid_path? request.path == Spid.configuration.acs_path end |
#valid_post? ⇒ Boolean
89 90 91 92 |
# File 'lib/spid/rack/sso.rb', line 89 def valid_post? request.post? && Spid.configuration.acs_binding == Spid::BINDINGS_HTTP_POST end |
#valid_request? ⇒ Boolean
106 107 108 |
# File 'lib/spid/rack/sso.rb', line 106 def valid_request? valid_path? && valid_http_verb? end |
#valid_response? ⇒ Boolean
102 103 104 |
# File 'lib/spid/rack/sso.rb', line 102 def valid_response? responser.valid? end |