Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Password protecting pages simply with rails - what should I do?

I'm now on level 7 of Hartl's rails tutorial book and I'm starting to think about my application in deployment. It's an app that allows about 12 social workers to communicate collaboratively and privately. Thus, I need to password protect it.

However, it also needs to be easy to use, very easy to use. A few of these people haven't used a computer before, and having logging on and sign-up processes would put them off completely.

Thus I want to create a landing page, where they have to type a password in (the same password for everybody), then it redirects to the 'discussion pages.' My first idea was to use some obfuscated javascript such that upon typing in the password, it redirects them to the discussion pages, but this doesn't sound very secure.

Can anyone recommend me a better way to do this in rails? Ideally they would only have to type it in once, and then it would authenticate them for all the pages automatically (by setting a cookie?) and anyone trying to access a page directly would be redirected to the authentication page.

Cheers in advance

like image 901
Joseph Avatar asked May 16 '12 18:05

Joseph


2 Answers

A very simple authentication option is available to you in this situation. I would suggest you watch the Ruby on Railscast episode 270. I think it just maybe what you are looking for.

like image 109
Tim Greider Avatar answered Sep 29 '22 21:09

Tim Greider


If you want really simple, you can use authenticate_or_request_with_http_basic

It's not a replacement for a real authentication system, e.g. Devise or AuthLogic however.

like image 24
x1a4 Avatar answered Sep 29 '22 20:09

x1a4