# HTTP Auth 401 Even on Valid Login

**URL:** <https://www.ruby-forum.com/t/http-auth-401-even-on-valid-login/167095>\
**Category:** Rails\
**Created:** [May 3, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/http-auth-401-even-on-valid-login/167095 "2009-05-03T21:30:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaggotChild](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7ea924/32.png) [@MaggotChild](https://www.ruby-forum.com/u/MaggotChild)\
**Post date:** [May 3, 2009, 9:30pm UTC](https://www.ruby-forum.com/t/http-auth-401-even-on-valid-login/167095/1 "2009-05-03T21:30:01Z")

</div>

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](http://localhost/admin/items/new)]
