Module: Rack::Cas::SessionStore::FileSystem
- Included in:
- Client
- Defined in:
- lib/rack/cas_client.rb
Instance Method Summary collapse
-
#delete_service_session_lookup(st) ⇒ Object
Removes a stored relationship between a ServiceTicket and a local Rails session id.
-
#filename_of_service_session_lookup(st) ⇒ Object
Returns the path and filename of the service session lookup file.
-
#read_service_session_lookup(st) ⇒ Object
Returns the local Rails session ID corresponding to the given ServiceTicket.
-
#store_service_session_lookup(st, sid) ⇒ Object
Creates a file in tmp/sessions linking a SessionTicket with the local Rails session id.
Instance Method Details
#delete_service_session_lookup(st) ⇒ Object
Removes a stored relationship between a ServiceTicket and a local Rails session id. This should be called when the session is being closed.
See #store_service_session_lookup.
44 45 46 47 48 |
# File 'lib/rack/cas_client.rb', line 44 def delete_service_session_lookup(st) st = st.ticket if st.kind_of? CASClient::ServiceTicket ssl_filename = filename_of_service_session_lookup(st) ::File.delete(ssl_filename) if ::File.exists?(ssl_filename) end |
#filename_of_service_session_lookup(st) ⇒ Object
Returns the path and filename of the service session lookup file.
51 52 53 54 |
# File 'lib/rack/cas_client.rb', line 51 def filename_of_service_session_lookup(st) st = st.ticket if st.kind_of? CASClient::ServiceTicket return "#{config[:session_dir]}/cas_sess.#{st}" end |
#read_service_session_lookup(st) ⇒ Object
Returns the local Rails session ID corresponding to the given ServiceTicket. This is done by reading the contents of the cas_sess.<session ticket> file created in a prior call to #store_service_session_lookup.
33 34 35 36 37 |
# File 'lib/rack/cas_client.rb', line 33 def read_service_session_lookup(st) st = st.ticket if st.kind_of? CASClient::ServiceTicket ssl_filename = filename_of_service_session_lookup(st) return ::File.exists?(ssl_filename) && IO.read(ssl_filename) end |
#store_service_session_lookup(st, sid) ⇒ Object
Creates a file in tmp/sessions linking a SessionTicket with the local Rails session id. The file is named cas_sess.<session ticket> and its text contents is the corresponding Rails session id. Returns the filename of the lookup file created.
21 22 23 24 25 26 27 |
# File 'lib/rack/cas_client.rb', line 21 def store_service_session_lookup(st, sid) st = st.ticket if st.kind_of? CASClient::ServiceTicket f = ::File.new(filename_of_service_session_lookup(st), 'w') f.write(sid) f.close return f.path end |