Class: Cassiopeia::BaseRack
Direct Known Subclasses
Constant Summary collapse
- CAS_RACK_SESSION_STORE =
Cassiopeia::CONFIG[:rack_session_store]
- CAS_RACK_SESSION_KEY =
Cassiopeia::CONFIG[:rack_session_key]
- CAS_TICKET_ID_KEY =
Cassiopeia::CONFIG[:ticket_id_key]
- CAS_TICKET_KEY =
Cassiopeia::CONFIG[:ticket_key]
- CAS_REQUEST_URI_KEY =
Cassiopeia::CONFIG[:rack_request_uri_key]
- CAS_QUERY_STRING_KEY =
Cassiopeia::CONFIG[:rack_query_string_key]
- CAS_SAVE_KEYS =
Cassiopeia::CONFIG[:rack_save_keys]
- CAS_UNIQUE_REQ_KEY =
Cassiopeia::CONFIG[:rack_unique_req_key]
- CAS_REQ_EXPIRES_AT_KEY =
Cassiopeia::CONFIG[:rack_session_store_expires_at_key]
- CAS_REQ_TIMEOUT =
Cassiopeia::CONFIG[:rack_session_store_timeout]
- CAS_REQ_REMOVE_RETURN =
Cassiopeia::CONFIG[:rack_remove_req_after_return]
Instance Method Summary collapse
- #cas_current_ticket(env) ⇒ Object
- #cas_current_ticket_valid?(env) ⇒ Boolean
- #enabled ⇒ Object
- #generate_expiration ⇒ Object
- #generate_req_key ⇒ Object
-
#initialize(app) ⇒ BaseRack
constructor
A new instance of BaseRack.
- #raise_missconfiguration(msg) ⇒ Object
- #response(env) ⇒ Object
- #restore_headers_required?(env) ⇒ Boolean
- #session(env) ⇒ Object
- #store_headers_required?(env) ⇒ Boolean
Constructor Details
#initialize(app) ⇒ BaseRack
Returns a new instance of BaseRack.
33 34 35 |
# File 'lib/cassiopeia/base_rack.rb', line 33 def initialize( app ) @app = app end |
Instance Method Details
#cas_current_ticket(env) ⇒ Object
20 21 22 |
# File 'lib/cassiopeia/base_rack.rb', line 20 def cas_current_ticket(env) session(env)[CAS_TICKET_KEY] end |
#cas_current_ticket_valid?(env) ⇒ Boolean
24 25 26 27 |
# File 'lib/cassiopeia/base_rack.rb', line 24 def cas_current_ticket_valid?(env) @ticket = cas_current_ticket(env) @ticket && ActiveSupport::TimeZone['UTC'].parse(@ticket[:expires_at]) >= Time.now.utc if @ticket && @ticket[:expires_at] end |
#enabled ⇒ Object
29 30 31 |
# File 'lib/cassiopeia/base_rack.rb', line 29 def enabled Cassiopeia::CONFIG[:requests_save_enabled] end |
#generate_expiration ⇒ Object
50 51 52 |
# File 'lib/cassiopeia/base_rack.rb', line 50 def generate_expiration Time.now.utc + CAS_REQ_TIMEOUT / 24.0 / 60.0 end |
#generate_req_key ⇒ Object
54 55 56 |
# File 'lib/cassiopeia/base_rack.rb', line 54 def generate_req_key UUIDTools::UUID..to_s end |
#raise_missconfiguration(msg) ⇒ Object
58 59 60 |
# File 'lib/cassiopeia/base_rack.rb', line 58 def raise_missconfiguration(msg) raise Cassiopeia::Exception::MissConfiguration.new "Cannot modify or delete cassiopeia request instance! Please, create table casssiopeia_requests[:uid, :expires_at, :data] or disable requests saving in configuration! (#{msg})" end |
#response(env) ⇒ Object
37 38 39 40 |
# File 'lib/cassiopeia/base_rack.rb', line 37 def response( env ) @status, @headers, @body = @app.call env [@status, @headers, @body] end |
#restore_headers_required?(env) ⇒ Boolean
42 43 44 |
# File 'lib/cassiopeia/base_rack.rb', line 42 def restore_headers_required?(env) env[CAS_QUERY_STRING_KEY] && env[CAS_QUERY_STRING_KEY].match(CAS_TICKET_ID_KEY.to_s) && env[CAS_RACK_SESSION_KEY] end |
#session(env) ⇒ Object
16 17 18 |
# File 'lib/cassiopeia/base_rack.rb', line 16 def session(env) env[CAS_RACK_SESSION_KEY] end |
#store_headers_required?(env) ⇒ Boolean
46 47 48 |
# File 'lib/cassiopeia/base_rack.rb', line 46 def store_headers_required?(env) !cas_current_ticket_valid?(env) end |