rubycas/rubycas-client — pull request #48 by amckaig-mdsol (2012-08-14 20:03:17+00:00)
Title: Use the 'service_ticket' column in ActiveRecord storage

Values stored in ActiveRecord sessions are not mapped onto database columns. They're serialized and stored in the `data` column. But [read_service_session_lookup] (https://github.com/rubycas/rubycas-client/blob/master/lib/casclient/tickets/storage/active_record_ticket_store.rb#L30) seems to be expecting service tickets to be stored in the `service_ticket` column of the sessions table:

```ruby
def read_service_session_lookup(st)
raise CASException, "No service_ticket specified." unless st
st = st.ticket if st.kind_of? ServiceTicket
session = ActiveRecord::SessionStore::Session.find_by_service_ticket(st) # <--
session ? session.session_id : nil
end
```

I'd expect it to be set in [store_service_session_lookup] (https://github.com/rubycas/rubycas-client/blob/master/lib/casclient/tickets/storage/active_record_ticket_store.rb#L21), but it seems to be stored in the session itself, instead:

```ruby
def store_service_session_lookup(st, controller)
raise CASException, "No service_ticket specified." unless st
raise CASException, "No controller specified." unless controller

st = st.ticket if st.kind_of? ServiceTicket
session = controller.session
session[:service_ticket] = st # <--
end
```

As a result, the service_ticket column of my sessions table is all NULLs. After this patch is applied, it's full of service tickets.

----

This seems to have been the case [for a long time] (https://github.com/rubycas/rubycas-client/commit/fa3f776e9f938712ca43787d3148e705f462eb28), so perhaps I'm missing something, but I can't see how this was ever working. Perhaps I'm doing it wrong. Your feedback would be appreciated, either way.