# Restful\_authentication, Internet Explorer, and unwanted http basic dialog

**URL:** <https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565>\
**Category:** Rails\
**Created:** [June 27, 2008, 4:59am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565 "2008-06-27T04:59:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [June 27, 2008, 4:59am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565/1 "2008-06-27T04:59:12Z")

</div>

I have a fairly bog-standard installation of restful\_authentication  
and run my app in Rails 2.1. Internet Explorer 6 and 7 are popping up  
an http basic authentication dialog instead of doing what all other  
browsers do: go to the login page. Any thoughts why?

I’ve modified the following method of authenticated\_system.rb, but  
there’s no difference before or after.

Before:

def current\_user  
@current\_user ||= (login\_from\_session || login\_from\_basic\_auth ||  
login\_from\_cookie) unless @current\_user == false  
end

After:

def current\_user  
@current\_user ||= login\_from\_session unless @current\_user == false  
end

Thanks for any help.

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [June 27, 2008, 5:08am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565/2 "2008-06-27T05:08:33Z")

</div>

I should qualify that: ‘before’ you can log in with http basic  
authentication, but ‘after’ you can’t. My issue is that I don’t want  
to see the http basic authentication dialog at all.

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [June 27, 2008, 5:53am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565/3 "2008-06-27T05:53:35Z")

</div>

The issue is in this method of authenticated\_system.rb:

```
def access_denied
  respond_to do |format|
    format.html do
      store_location
      redirect_to new_session_path
    end
    format.any do
      request_http_basic_authentication 'Web Password'
    end
  end
end

```

For some reason Internet Explorer is falling through to format.any -  
something’s not quite working with its accept headers, it seems.  
Compare:

> **[Strange behaviour of respond\_to in IE](https://rituonrails.wordpress.com/2006/12/10/strane-behaviour-of-respond_to-in-ie/)**
>
> In recent days i have monitored a very strange behaviour of respond\_to in IE.I am sharing my experience in hope that somebody might explain it to me. As i cudnt find anything related to this from m…

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [June 27, 2008, 9:43am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565/4 "2008-06-27T09:43:08Z")

</div>

Alter access\_denied to add this line (right below “def access\_denied”):

request.format ||= :html if request.env[‘HTTP\_USER\_AGENT’] =~ /msie/i

It’s a quick hack but it seems to work fine so far for me. The  
problem is, as you’ve stated, IE doesn’t seem to send the right accept  
headers (if any) when fetching a URL without an explicit extension in  
the URL. For instance if you have a /users/4 URL, it will bring up  
the basic authentication dialog, but /users/4.html will correctly  
redirect to new\_session\_path.

-J.

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [May 7, 2009, 6:06am UTC](https://www.ruby-forum.com/t/restful-authentication-internet-explorer-and-unwanted-http-basic-dialog/141565/5 "2009-05-07T06:06:22Z")

</div>

Chris B. wrote:

> I have a fairly bog-standard installation of restful\_authentication  
> and run my app in Rails 2.1. Internet Explorer 6 and 7 are popping up  
> an http basic authentication dialog instead of doing what all other  
> browsers do: go to the login page. Any thoughts why?
> 
> I’ve modified the following method of authenticated\_system.rb, but  
> there’s no difference before or after.
> 
> Before:
> 
> def current\_user  
> @current\_user ||= (login\_from\_session || login\_from\_basic\_auth ||  
> login\_from\_cookie) unless @current\_user == false  
> end
> 
> After:
> 
> def current\_user  
> @current\_user ||= login\_from\_session unless @current\_user == false  
> end
> 
> Thanks for any help.

I had the same problem. I think that itÂ´s for the Mime Types (I observe  
with the debugger that Firefox and IE have differents priorities using  
images)…

So I coud fix the problem modifiying the access\_denied method from the  
lib/AuthenticatedSystem module as follows:

def access\_denied  
respond\_to do |format|  
#…particular formats if itÂ´s neccesary  
format.any do  
store\_location  
redirect\_to new\_session\_path  
end  
end  
end

I hope this will be useful

Fer  
Argentina
