Central Authentication Service (CAS) with rails - ruby-on-rails

I am developing a web application with ruby on rails. I am trying to link the authentification page of my webapp to a Central Authentication Service (CAS).
So, whenever someone tries to start my webapp , my app should :
Check if the user is already connected to the CAS
1/ if he is already connected, the app will start and he can use its services normally
2/ if the user is not connected to the app, a login page will be displayed, where he has to type his password and login. These password and login will be tested on the CAS, and according to the result of the test will be allowed to start the webapp or not.
This seems a bit complicated to implement. I need help because i am new to ruby on rails.
thanks in advance

use the devise gem,
here is a railscast to show you how railscast example
and here is the gem link
here is a CAS specific gem for devise
hope that helps

Related

Ruby on Rails - LDAP based authentication

this is my first post on SO, but I have been reader for long time :)
I'm currently working on LDAP authentication for Rails app. I'm using ruby Net::LDAP library - I'm abble to succesfully bind and login using technical account and search for a specific user. What I don't know how to do, is how to verify finded AD user password with the one he provided during logon. Because of AD policy restriction, I can make binding only from the technical account - so the use sollution with binding every logging user to AD cannot be used here.
Thanks for any help
Check out .bind_as: According to the docs
http://www.rubydoc.info/gems/ruby-net-ldap/Net/LDAP#bind_as-instance_method
it is for testing authentication credentials.

Session retention after login on iOS app and Devise with Rails

I'm building an iOS app with Rails on the back-end.
The Rails application uses Devise for authentication and I want to use the same service for the authentication on the iOS app. Is there any way that after authenticating, keeping the session even after the app restarts, so that it goes straight to the content of the app instead of the login screen?
I've looked around, but haven't found a clear answer.
Thanks on advance!
One solution could be to extend the existing devise models and controllers to also handle a token based authentication system. Based on the request type html or json, the app can choose to authenticate a user either by the authentication token and email or a combination of username/email and password.
The authentication token could could be saved on the client side and reset only when the user logs out.
I was recently working on the same problem and found these sources to be extremely useful.
https://gist.github.com/josevalim/fb706b1e933ef01e4fb6
http://www.soryy.com/blog/2014/apis-with-devise/
https://github.com/lynndylanhurley/devise_token_auth

Rails LDAP and Devise Authentication automatically from Active Directory

I am trying to authenticate users from Active Directory using devise and ldap in Rails .
I am successful in authenticating from Login Credentials which users enter.
But once user is authenticated his credentials will be saved in session.
I do not want users to login using credentials. But the application
should detect Domain once user logs into windows and use Windows authentication
if that Domain is present in Active Directory.
I followed this : http://everything-ruby.blogspot.in/2011/04/installing-windows-server-2008-ee-with_13.html and works fine.
Can anyone guide me in right path to achieve this?
Thanks in Advance
Kind of an old post but others may be interested:
It sounds to me that what you're trying to achieve is single sign-on. If so then you probably want to look into CAS (Central Authentication Services) instead. AD supports this and it's pretty easy in Rails as well.

Facebook login on iPhone. Authenticate with Rails Backend (Devise+Omniauth)

I am trying to implement a facebook user authentication in my iOS6 App through my Rails Backend running with Devise using omniauth. I am looking for a step by step guide how to setup my API and Devise + Authentication.
I only have a only have a rough knowledge about how to do that.
(on App) check if the user signs in on his facebook on iPhone
iPhone is authenticated client sided on Facebook. FB passes me his mobile auth token
I send my auth token or auth hash to my rails backend via API RESTful SSL.
Rails receives the Token and checks if it is valid. ( What command uses the least traffic against FB Graph API? with Koala Gem)
If valid. Check if the user already exists. If not, create a new user.
Create a new session.
Is this correct?
Are there any good examples?
Thank you very much.
I'm not familiar with the iPhone piece, but your approach after that is generally accurate. The only exception is that you would typically use provider + uid to find or create a user, rather than a token. That might be what you meant by your #5, but it wasn't clear to me.
Beyond that, there is a good (paid) Railscast on the subject of Omniauth + Devise, which would probably be worth the price for you:
http://railscasts.com/episodes/235-devise-and-omniauth-revised
It covers how you can receive and handle the auth hash, and it gives you a nice starting point for what your methods will look like.
if you don't access to pro episodes i have some links to help.
http://jessewolgamott.com/blog/2012/01/19/the-one-with-a-json-api-login-using-devise/
you can also look into it
http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
Nice and easy to code
http://blog.joshsoftware.com/2010/12/16/multiple-applications-with-devise-omniauth-and-single-sign-on/
I hope these will work for you :)
http://www.orhancanceylan.com/rails-twitter-and-facebook-authentications-with-omniauth-and-devise/

How to get the rubycas-server login form to display?

I have installed rubycas-server on my server. I have a ruby app that supports CAS on mysite.com. I would like to have the rubycas-server login page at login.mysite.com.
I have followed the instructions at http://code.google.com/p/rubycas-server/wiki/HowToConfigure and configured my config.yml file.
I have started the rubycas-server but I don't see a login form at login.mysite.com. There isn't anything on login.mysite.com. I have setup the uri_path to login.mysite.com. I thought that it would display the login form when I start the rubycas-server but it doesn't. I guess I am still missing something. What am I suppose to put on login.mysite.com in order for the login page to display? Is there suppose to be another ruby app?
Sorry, I am new to this.
Remember that the CAS is a single sign-on app and the CAS login page is meant to be central to all of your applications. So a typical usage would be that you have your CAS server running on one machine, and the login will be at somedomain.com/cas. Then you have a bunch of applications that want to authenticate, at mysite1.com, mysite2.com, etc. If you try to browse to a CAS-protected page in one of those applications, you'll be redirected to somedomain.com/cas, where you'll sign in, and then CAS will redirect you back to the page you wanted on, say, mysite2.com.
Out of the box, you should see the login by going to the domain that rubycas-client is installed on and going to /cas.
Basically, it sounds like you're expecting the login page to be part of your application, and with CAS, it's not.

Resources