Rubycas: empty cookies when using CASClient::Frameworks::Rails::Filter login_to_service() method

321 views Asked by At

I found RubyCAS very useful tool, but have problems when logging in from a form on my site. The form is default & hidden fields a follows:

  <td id="submit-container">
    <input type="hidden" id="lt" name="lt" value="<%= @lt %>" />
    <input type="hidden" id="service" name="service" value="<%= @service %>" />
    <input type="submit" class="button" accesskey="l" value="Поехали"
           tabindex="4" id="login-submit" />
  </td>

The controller with custom login action looks like

class UsersController < ApplicationController
 before_filter CASClient::Frameworks::Rails::Filter, :except => [:new, :create, :cas_login]

 def cas_login
    credentials = { :username => params[:username], :password => params[:password]}
    client = CASClient::Frameworks::Rails::Filter
    @resp = client.login_to_service(self, credentials, 'http://local.mysite:3000/users/login')

    if @resp.service_redirect_url.nil?
      # if login failed, redisplay the page that has your login-form on it                                                                                                                                          
      flash[:error] = "Invalid email or password"

      redirect_to root_url
    else                                                                                                                                                                                 
      return redirect_to(@resp.service_redirect_url)
    end
  end
end

The problem: So after successful login in first app, and setting cookie in rubycas-server-1.1.1/lib/casserver/server.rb:

response.set_cookie('tgt', tgt.to_s)

I have empty cookies when trying to open another app using rubycas-server

When login to first app using rubycas-server out-of-the-box form everything is OK, and I logged onto second automatically

Please help! spent 3 days on this problem!

0

There are 0 answers