Forum: Ruby on Rails HTTP Auth 401 Even on Valid Login

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5c262b1a445eb969fd2d411316f5365e?d=identicon&s=25 MaggotChild (Guest)
on 2009-05-03 21:30
(Received via mailing list)
I can't understand why authenticate_or_request_with_http_basic keeps
failing even though I am entering the correct info.

If I try to access /admin/items/new, I enter the correct info but I
keep getting prompted.

The strange part is that when I cancel out, I get "HTTP Basic: Acce".

Here's the controllers:

class Admin::BaseController < ApplicationController
  before_filter :authenticate
  def authenticate
    authenticate_or_request_with_http_basic do |name, pass|
        name == 'h' && pass == 'x'
    end
  end
end

class Admin::ItemsController < Admin::BaseController
  def new
    @item = Item.new
    @category = 'New Item'
    @categories = Category.find :all, :order=>'name'
  end

  #etc...
end

The log:

Processing ItemsController#new (for localhost at 2009-05-03 12:20:05)
[GET]
  Session ID:
BAh7CDoSYXV0aGVudGljYXRlZFQ6DGNzcmZfaWQiJTYxZjNiYjBlY2Q2MWYz
MTA3ZmQ0Y2ZiOTFhMmRlMWQxIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy
OjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--
f03480a81df51ccf0c5d4a2a6e80f3aad10366cc
  Parameters: {"action"=>"new", "controller"=>"admin/items"}
Filter chain halted as [:authenticate] rendered_or_redirected.
Completed in 0.00136 (733 reqs/sec) | Rendering: 0.00112 (82%) | DB:
0.00000 (0%) | 401 Unauthorized [http://localhost/admin/items/new]
This topic is locked and can not be replied to.