gitb
gitb

Reputation: 1100

How can I password-protect a page/action with only a password

I want to require that authenticated users provide a password to access a certain page/action.

I know that RoR has authenticate_or_request_with_http_basic() that can be used to protect an action but that requires that a name and password be entered and I'm only interested in requiring a password.

Upvotes: 0

Views: 519

Answers (1)

Esse
Esse

Reputation: 3298

Well, you can always leave user blank.

If it isn't an option I have some bad news - browser will always ask for user and password when using http basic authentication.

However there are some different options:

  • providing some key in url that works as password (quite unsecure)
  • login box with password field only, that (when password is correct) set session[:auth] = true. And appropriate before_filter in your ApplicationController.
  • Normak authentication but with one field (password only) - I'm not sure if it would be good.

I think second option would be best here (if of course, leaving http basic auth login/password box isn't an option).

Upvotes: 2

Related Questions