google-code-export / rubycas-client

Automatically exported from code.google.com/p/rubycas-client
1 stars 1 forks source link

session file creation needs to prepend RAILS_ROOT #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  Try to authenticate using rubycas-client's rails filter.
2.  Go to CAS authentication page, type username and password.
3.  Get Application Error.

Log reveals the problem:

Errno::ENOENT (No such file or directory -
tmp/sessions/cas_sess.ST-4913-SckQxHY3KhVAydpBFfsoBbgJnPJikbV7eq5-aws-p1):

/vendor/plugins/rubycas-client/lib/casclient/frameworks/rails/filter.rb:231:in
`initialize'

What version of the product are you using? On what operating system?

rubycas-client v 2.1.0. rails 2.0.2. ruby 1.8.6. SunOS 5.8

Please provide any additional information below.

The problem is at filter.rb, line 231:

            f = File.new(filename_of_service_session_lookup(st), 'w')

This calls filename_of_service_session_lookup to get a pathname for the
session file.  This method returns a relative path, without prepended
RAILS_ROOT.  Comments on this method say that a calling function should
prepend RAILS_ROOT, but this is not done at line 231:

          # Returns the path and filename of the service session lookup file.
          # The returned path is relative, starting at RAILS_ROOT, so you may
          # need to prepend RAILS_ROOT to the return value and/or call
          # File.expand_path.
          def filename_of_service_session_lookup(st)
            st = st.ticket if st.kind_of? ServiceTicket
            return "tmp/sessions/cas_sess.#{st}"
          end

I was able to fix the problem by changing the last line of this method to
            return "#{RAILS_ROOT}/tmp/sessions/cas_sess.#{st}"
Is there a reason this function doesn't prepend RAILS_ROOT?

Interestingly, I had this problem on my production machine but not on
my development machine.

Original issue reported on code.google.com by fiddloso...@gmail.com on 21 Jun 2008 at 12:57

GoogleCodeExporter commented 9 years ago

Original comment by matt.zuk...@gmail.com on 23 Sep 2008 at 5:42

GoogleCodeExporter commented 9 years ago
There was probably a reason why I didn't automatically prepend RAILS_ROOT to the
filename, but I've no idea now what that might have been.

RAILS_ROOT is now prepended (as of ref 172). Thanks for pointing this out.

Original comment by matt.zuk...@gmail.com on 1 Oct 2008 at 7:20

GoogleCodeExporter commented 9 years ago

Original comment by matt.zuk...@gmail.com on 1 Oct 2008 at 8:47