rubycas / rubycas-server

Provides single sign-on authentication for web applications, implementing the server-end of Jasig's CAS protocol.
http://rubycas.github.com
Other
628 stars 270 forks source link

Cross domain ajax between rubycas client apps #205

Closed shenhf closed 10 years ago

shenhf commented 10 years ago

I have two rails app(different domain) using rubycas do sso job.

There is a link on page(belongs to app1with domain http://localhost:3000): = link_to "User Info", "http://localhost:3000/users/#{current_user.id}/info", class: 'btn btn-success btn-sm', remote:true which do ajax call to get user information( use rack-cors gem)

The problem is app2 not act as an ajax call, here is the log:

Started GET "/users/2/info" for 127.0.0.1 at 2014-03-18 15:10:57 +0800 Processing by UsersController#info as JS ...

Guessed service url: "http://localhost:3000/users/2/info" Generated login url: https://localhost:4433/cas/login?service=http%3A%2F%2Flocalhost%3A3000%2Fusers%2F2%2Finfo ...

Started GET "/users/2/info?ticket=ST-1395126657rQtGejpcwje5nTMNbE2" for 127.0.0.1 at 2014-03-18 15:10:57 +0800 Processing by UsersController#info as HTML Parameters: {"ticket"=>"ST-1395126657rQtGejpcwje5nTMNbE2", "id"=>"2"}

Here is the problem, after redirect by cas server, it's not an ajax call from app1, it is treated as a normal request as app2 it self!

Is there any solution or suggestion?

mitfik commented 10 years ago

rubycas-server do not support ajax calls. There is work in progress on rubycas-server-core for that but it will take some time until we will release it. There is a fork[1] where I implemented API which can be used for ajax calls, which maybe will help you. But this is nothing which is maintained and all that functionality soon will end up in rubycas-server-core.

[1] https://github.com/mitfik/rubycas-server/tree/my_master